#Coding=utf-8 fromSelenium.webdriverImportRemotedr= Remote (command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities={'Platform':' any', 'Browsername':'Firefox', 'version':"', 'javascriptenabled': True}) Dr.get ("https://www.baidu.com") dr.find_element_by_id ("kw"). Send_keys ("Grid") dr.find_element_by_id ("su"). Click ()Print("OK") Dr.quit ()
This piece of code has been an error, do not know the reason, the online review of various methods after verification can not, change to change, and finally I do not know that way to change the good, can only put all the problems recorded. The error was not at the time, can only recall the approximate error message:
1, the first troubleshooting, found that the browser installation path is not placed in the environment variables, corrected, error
2, There are users of the solution Is: open ie-set-internet Options-lan LAN Settings-proxy server. This item is not Checked. My IE is not checked at this Location. So this workaround doesn't work
3. Error hint: The path to the driver executable must is set by the Webdriver.gecko.driver system property; For more information, See https://github.com/mozilla/ge ... The latest version can be downloaded fromhttps://github.com/mozilla/ge ...
After download, put Geckodriver decompression in the installation directory, add the PATH environment variable and run still error
4 Error [10061]. Forgot to run selenium server.
5, The runtime browser is repeated to open multiple errors,
The workaround is: add ' marionette ' to the Code: False to run successfully.
The above is the problem I encountered, the specific error message is not clear, probably remember, but also to do a Lesson.
After encountering an error, direct, solve the problem after the Filing.
Depressed is: the problem solved, but I do not know in the end is that way to Solve.
Summarize:
Python+selenium using remote to launch the Browser:
1. Start Selenium Server first
2. Change the code as follows
#Coding=utf-8 fromSelenium.webdriverImportRemotedr= Remote (command_executor='Http://127.0.0.1:4444/wd/hub', Desired_capabilities={'Platform':' any', 'Browsername':'Firefox', 'version':"', 'javascriptenabled': True,'Marionette': False}) Dr.get ("https://www.baidu.com") dr.find_element_by_id ("kw"). Send_keys ("Grid") dr.find_element_by_id ("su"). Click ()Print("OK") Dr.quit ()
' Marionette ': False Marionette is a Python client that allows a gecko-based browser or device running remote control to run a marionette server, including desktop Firefox and Firefox os. This parameter is Firefox special.
The above about marionette interpretation, refer to the Book of automated tests by the Zerg selenium2, in p242
Python+selenium Remote startup Firefox error summary