Thirumal
Thirumal

Reputation: 101

How to use Safari Browser in Selenium Webdriver using Python bindings

I am not able to launch safari browser from Selenium web driver. I am using Python bindings. Could not find any reference that provided detailed steps for Python. I am aware there is a related question on stackoverflow, but it doesn't answer for python - python selenium webdriver safari driver

Followed the Documentation on http://code.google.com/p/selenium/wiki/SafariDriver , downloaded and installed safari developer certificate. This doc has code for Java and not for python bindings.

Below is my code(I am using desired capabilities) Not sure what am I missing here -

from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from selenium import webdriver

browser = webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.SAFARI)
browser.get('http://www.google.com')
browser.close()

Upvotes: 3

Views: 5722

Answers (1)

Hairr
Hairr

Reputation: 1108

From the looks of it, you're trying to open a webpage with a webbrowser. Why not use "webbrowser"? It's easy to get the webbrowser have safari as default:

import webbrowser
browser = webbrowser.get('safari')
browser.open("http://www.google.com/")

As I can't selenium set up, I'm not sure if this is what you want. Who knows, it could be an alternative?

Upvotes: 1

Related Questions