简体   繁体   中英

Why is selenium not working properly on my mac?

I'm using python 3 and selenium 2.53.6 on mac and it does open firefox but not to the page I specified. I try to open "inventwithpython.com" but all my program does is launch firefox and return this error.

Below is my code:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get('http://inventwithpython.com')

I also getting below error:

File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/selenium/webdriver/firefox/firefox_binary.py", line 108, in _wait_until_connectable % (self.profile.path)) selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/4c/gsw7v5b118j406zxj3lxctt40000gn/T/tmpv963_mt0 If you specified a log_file in the FirefoxBinary constructor, check it for details.

can you try this? and let me know what happenes?

#!/your/shebang/line/python3

from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('/your/path/to/actual/firefox/binary')
driver = webdriver.Firefox(firefox_binary=binary)
driver.get('http://inventwithpython.com')

make sure the path to binary is the actual one you launch when you touch Firefox normally.

EDIT:

oh and before i forget, make sure you do this as well. just to be sure.

pip install -U selenium

because there was a fix for profiles a bit ago if i remember right. so lets make sure that's not a thing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM