I want to use Safari as the browser from python, and the code is fairly easy:
from selenium import webdriver
driver = webdriver.Safari()
url = 'https://www.gmail.com/'
driver.get(url)
I am using the latest version of Safari, 11.0.3,
In preferences-extension, I have WebDriver installed,
In develop on menu, I have "allow Remote Automation" enabled.
I'm using python 3.5, selenium 3.10.0
While running the code above, I got the following Error message:
Traceback (most recent call last):
File "/Users/hwang/Documents/Lumi_personal/Coding/sandbox/testSelenium.py", line 2, in <module>
driver = webdriver.Safari()
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/safari/webdriver.py", line 49, in __init__
self.service.start()
AttributeError: 'WebDriver' object has no attribute 'service'
Any help is appreciated! Thanks in advance!
I had the same issue with selenium 3.10, but not with 3.9.
Apparently, there's a bug in version 3.10 according to: https://github.com/SeleniumHQ/selenium/issues/5578
My temporary solution is to uninstall selenium 3.10, and install 3.9:
pip uninstall selenium
pip install selenium==3.9
And it should solve the problem.