from selenium.webdriver import Remote import time from selenium.webdriver.common.desired_capabilities import DesiredCapabilities driver = Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities={'platform': 'ANY', 'browserName':'firefox', 'version': '', 'javascriptEnabled': True}) driver.get('http://www.baidu.com') title=driver.title print (title) time.sleep(3) driver.quit()
我是这样写的
但在selenium server 出现错误:
Driver info: driver.version: unknown at java.util.concurrent.FutureTask.report(Unknown Source) at java.util.concurrent.FutureTask.get(Unknown Source) at org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSessi on.java:183) at org.openqa.selenium.remote.server.DefaultSession.<init>(DefaultSessio n.java:119) at org.openqa.selenium.remote.server.DefaultSession.createSession(Defaul tSession.java:95) 省略部分 Caused by: java.lang.IllegalStateException: The path to the driver executable mu st be set by the webdriver.gecko.driver system property; for more information, s ee https://github.com/mozilla/geckodriver. The latest version can be downloaded from https://github.com/mozilla/geckodriver/releases
编译器里也是同样的错误:
selenium.common.exceptions.WebDriverException: Message: The path to the driver executable must be set by the webdriver.gecko.driver system property; for more information, see https://github.co
这是什么原因?
geckodriver.exe我也放到firefox目录了
这个可执行文件需要加到path中,试试看,之前也遇到过,百度基本都能解决
path加过了,不行