Prerequisites
Settings > Safari > Details > Turn on "Remote automation" on your own iPhone.
Connect the iPhone with your Mac PC where Selenium codes run and then choose "Trust".
Running a website automation test on your own iPhone with Selenium
Source code
from time import sleep
from selenium import webdriver
from selenium.webdriver.safari.options import Options as SafariOptions
# Use Options to set capabilities instead of DesiredCapabilities after Selenium 4
safari_options = SafariOptions()
safari_options.set_capability("platformName", "ios")
driver = webdriver.Safari(options=safari_options)
driver.get("https://google.com")
sleep(10)
Top comments (0)