DEV Community

I.G
I.G

Posted on

Safari automation test on your own iPhone with Selenium in 2023

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)
Enter fullscreen mode Exit fullscreen mode

Top comments (0)