Script: (open Firefox browser, go to Baidu Web page, search selenium)
from Import = webdriver. Firefox (); Browser.get ("http://www.baidu.com"); browser.find_element_by_id ( "kw"). Send_keys ("selenium"); browser.find_element_by_id ("su"). Click (); Browser.quit ();
Executive PIN This report error 1:
Traceback (most recent): File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\common\service.py", line 74,inchStart stdout=self.log_file, stderr=self.log_file) File"D:\2017\programming language\python\installpath\lib\subprocess.py", line 707,inch __init__Restore_signals, Start_new_session) File"D:\2017\programming language\python\installpath\lib\subprocess.py", Line 990,inch_execute_child Startupinfo) Filenotfounderror: [Winerror2] The system could not find the file specified. During handling of the above exception, another exception Occurred:traceback (most recent call last): File"D:\2017\programming language\python\installpath\scripts\baidu.py", Line 3,inch<module>Browser=Webdriver. Firefox (); File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\firefox\webdriver.py ", line 142,inch __init__Self.service.start () File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\common\service.py", line 81,inchstart Os.path.basename (self.path), self.start_error_message) Selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to is in PATH.
mentioned here Geckodriver Drive, selenium3.x, Firefox browser driver Independent, need to install separately;
Workaround: Download the Geckodriver driver and place it in the Python installation path, making sure that the path is added to path;
Execute the script again, error 2:
Traceback (most recent): File"D:\2017\programming language\python\installpath\scripts\baidu.py", Line 3,inch<module>Browser=Webdriver. Firefox (); File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\firefox\webdriver.py ", Line 152,inch __init__keep_alive=True) File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\remote\webdriver.py ", line 98,inch __init__self.start_session (desired_capabilities, browser_profile) File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\remote\webdriver.py ", line 188,inchstart_session Response=Self.execute (command.new_session, parameters) File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\remote\webdriver.py ", line 256,inchExecute Self.error_handler.check_response (response) File"D:\2017\programming language\python\installpath\lib\site-packages\selenium\webdriver\remote\errorhandler.py ", line 194,inchCheck_responseRaiseexception_class (message, screen, StackTrace) Selenium.common.exceptions.WebDriverException:Message: Unable To find a matching set of capabilities
Workaround:
1. Check native Java version, selenium3.x only support java8 version above, here meet the requirements;
2. Geckodriver version is v0.16.1, Firefox browser version is 45, uninstall Firefox, install the latest version of Firefox version 53;
Run the script to execute normally.
python3.6.1+selenium3.0 environment installation problem and solution