[英]selenium python problem with loading page driver.get('http://page.com/') open empty window
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
browser = webdriver.Firefox(executable_path=r'/usr/bin/firefox')
browser.get("http://google.com/")
Ubuntu 16 LTS user here.How to fix this empty window issue after I enter url and is no loaded page there. Ubuntu 16 LTS 用户在这里。如何在我进入 url 并且那里没有加载页面后解决这个空的 window 问题。
Output: Output:
> > Traceback (most recent call last): File "/home/pc/PycharmProjects/calculator/test.py", line 781, in <module>
> browser = webdriver.Firefox(executable_path=r'/usr/bin/firefox') File
> "/home/pc/PycharmProjects/calculator/venv/lib/python3.5/site-packages/selenium/webdriver/firefox/webdriver.py",
> line 164, in __init__
> self.service.start() File "/home/pc/PycharmProjects/calculator/venv/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
> line 98, in start
> self.assert_process_still_running() File "/home/pc/PycharmProjects/calculator/venv/lib/python3.5/site-packages/selenium/webdriver/common/service.py",
> line 111, in assert_process_still_running
> % (self.path, return_code) selenium.common.exceptions.WebDriverException: Message: Service
> /usr/bin/firefox unexpectedly exited. Status code was: 0
You need to provide geckodriver
path not firefox.您需要提供
geckodriver
路径而不是 firefox。 Check your firefox browser version and you can download compatible geckodriver from Here检查您的 firefox 浏览器版本,您可以从这里下载兼容的 geckodriver
browser = webdriver.Firefox(executable_path="path of geckodriver")
Sample code示例代码
browser = webdriver.Firefox(executable_path="/Users/username/Location/geckodriver")
browser.get("https://google.com")
You can add the path to your webdriver in the PATH
system variable您可以在
PATH
系统变量中添加 webdriver 的路径
export PATH=$PATH:/path/to/driver/firefox-driver
Add it to /home//.profile file to make it permanent.将其添加到 /home//.profile 文件以使其永久化。
Then you dont need executable_path=''那么你不需要 executable_path=''
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.