Hi! I need your help. I have a problem with running selenium autotests (Python language) on mobile Safari using Appium. I have Xcode installed, appium server. I run them every time before running the autotests. My test looks like this:
import unittest
from appium import webdriver
import os
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class MyTestCase(unittest.TestCase):
def test_open_website(self):
URL = "https://medium.com"
desired_caps = {
"platformName": "iOS",
"platformVersion": "16.4",
"deviceName": "iPhone Simulator",
"browserName": "Safari",
"udid": "6C2BBB6F-6DBA-4704-8C9F-4E4D7A40A5B8",
}
# desired_caps = {
# "platformName": "iOS",
# "platformVersion": "16.4",
# "deviceName": "iPhone Simulator",
# "udid": "6C2BBB6F-6DBA-4704-8C9F-4E4D7A40A5B8",
# "automationName": "XCUITest",
# "browserName": "Safari",
# "useNewWDA": True,
# "newCommandTimeout": 600,
# }
# "http://localhost:4723/wd/hub"
driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
# driver = webdriver.Remote("https://medium.com", desired_caps), "http://localhost:4723/wd/hub"
# wait = WebDriverWait(driver, 15)
# element = wait.until(EC.presence_of_element_located((By.ID, "element_id")))
# driver.execute_script("window.location.href = 'https://medium.com'")
driver.get("https://medium.com")
current_url = driver.current_url
assert URL == current_url
if name == ‘main’:
unittest.main()
Safari opens in the simulator, but instead of opening the site, it passes the localhost value to a string. And I get this error: selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Mobile Safari cannot open ‘http://0.0.0.0:4723/welcome’ after 25.588s. Its process com.apple.mobilesafari does not exist in the list of Simulator processes
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Mobile Safari cannot open ‘http://0.0.0.0:4723/welcome’ after 25.588s. Its process com.apple.mobilesafari does not exist in the list of Simulator processes
at getResponseForW3CError (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/errors.js:804:9)
at asyncHandler (/Applications/Appium Server GUI.app/Contents/Resources/app/node_modules/appium/node_modules/appium-base-driver/lib/protocol/protocol.js:380:37)