Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()
like image 596
Thirumal Avatar asked Mar 08 '26 10:03

Thirumal


1 Answers

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?

like image 188
Hairr Avatar answered Mar 09 '26 23:03

Hairr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!