Fedora23 install and use web automation testing tools selenium and fedora23selenium

Source: Internet
Author: User
Tags seleniumhq

Fedora23 install and use web automation testing tools selenium and fedora23selenium

1. pip install selenium requires root permission

2. Run openchrome. py:

from selenium import webdriverfrom selenium.common.exceptions import NoSuchElementExceptionfrom selenium.webdriver.common.keys import Keysimport timebrowser = webdriver.Chrome() # Get local session of Chromebrowser.get("http://www.bing.com") # Load pageassert "Bing" in browser.titleelem = browser.find_element_by_name("q") # Find the query boxelem.send_keys("seleniumhq" + Keys.RETURN)time.sleep(0.2) # Let the page load, will be added to the APItry:    browser.find_element_by_xpath("//a[contains(@href,'http://docs.seleniumhq.org/')]")except NoSuchElementException:    assert 0, "can't find seleniumhq"browser.close()              

Error:

FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'

Selenium. common. exceptions. WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Use the prompt link to download chromedriver. Download and unzip it.

Add the PATH of chromedriver to the path variable: vim ~ /. Bash_profile

PATH=$PATH:$HOME/.local/bin:$HOME/bin:/home/codc/.browserdriver/chromedriverexport PATH

Append/home/codc/. browserdriver/chromedriver to the end of PATH.

Source ~ /. Bash_profile make the path take effect

Run python openchrome. py again, and an error is returned:

Selenium. common. exceptions. WebDriverException: Message: unknown error: Chrome version must be> = 55.0.2883.0
(Driver info: chromedriver = 2.28.455506 (18f6627e265f442aeec9b6661a49fe819aeeea1f), platform = Linux 4.2.3-300. fc23.x86 _ 64 x86_64)

The reason is that the downloaded chromedirver is the latest version, and the chrome version is older, and chrome is updated: dnf update google-chrome

$sudo dnf update google-chromeRPM Fusion for Fedora 23 - Free - Updates                       112 kB/s | 371 kB     00:03    Last metadata expiration check performed 0:00:00 ago on Sun Mar 26 17:01:21 2017.Dependencies resolved.================================================================================================ Package                   Arch        Version                Repository                   Size================================================================================================Upgrading: google-chrome-stable      x86_64      57.0.2987.110-1        google-chrome-unstable       45 MTransaction Summary================================================================================================Upgrade  1 PackageTotal download size: 45 MIs this ok [y/N]: y

Google-chrome needs to configure the source repository used by dnf chrome, Which is downloaded from rpmfusion free by default.

Note: The message geckodriver is displayed in firefox.

FileNotFoundError: [Errno 2] No such file or directory: 'geckodriver'During handling of the above exception, another exception occurred:Traceback (most recent call last):  File "openfirefox.py", line 6, in <module>    browser = webdriver.Firefox() # Get local session of firefox  File "/usr/lib/python3.4/site-packages/selenium/webdriver/firefox/webdriver.py", line 145, in __init__    self.service.start()  File "/usr/lib/python3.4/site-packages/selenium/webdriver/common/service.py", line 81, in start    os.path.basename(self.path), self.start_error_message)selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH. 

  

[1] http://www.cnblogs.com/fnng/archive/2013/05/29/3106515.html

[2] https://github.com/mozilla/geckodriver/releases

[3] http://stackoverflow.com/questions/40208051/selenium-using-python-geckodriver-executable-needs-to-be-in-path

[4] https://chromedriver.storage.googleapis.com/index.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.