Python Selenium - Open Safari Browser
Python Selenium - Open Safari
In this tutorial, you shall learn how to open Safari browser, using Selenium, in Python language.
Prerequisites
We have to set the Allow Remote Automation to open Safari browser using Selenium.
To set Allow Remote Automation in Safari browser,
- Open Safari browser.
- Click on Develop menu.
- Make sure the menu item Allow Remote Automation is checked. If not checked already, click on it.
Steps to open Safari browser using Selenium Python
Step 1
Import webdriver module from selenium module.
from selenium import webdriver
Step 2
Create a Safari driver instance using webdriver.Safari() class.
driver = webdriver.Safari()
Example
In the following example, we followed the above said steps to create a Safari driver instance, and open a Safari browser window.
Python Program
from selenium import webdriver
# Setup Safari driver
driver = webdriver.Safari()
# Navigate to the url
driver.get('/tmp/selenium/index.html')
# Close the driver
driver.quit()
Screenshot
Summary
In this Python Selenium Tutorial, we have seen how to create a Safari driver instance and open a Safari browser window.