Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install Selenium on Linux system

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to install Selenium Linux system, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to understand it!

Selenium is a series of Web-based automation tools that provide a set of test functions to support Web automation testing, but how to install Selenium in a Linux system?

About Selenium: Selenium is an automated testing tool for Web applications. The Selenium test runs directly in the browser, just like a real user is working on it. Supported browsers include IE (7, 8, 9, 10, 11), Mozilla Firefox,Safari,Google Chrome,Opera, etc.

The main features include: testing compatibility with browsers-testing your application to see if it works well on different browsers and operating systems.

Test system function-create regression tests to check software functions and user requirements. Supports automatic recording of actions and automatic generation of test scripts in .net, Java, Perl and other languages.

Selenium is also an open source framework released using the Apache License 2.0 protocol.

Specific method for installing Selenium in Linux system: install pytest in the container. If you cannot find pytest by adding a soft connection, set the soft connection find /-name pytest / var/jenkins_home/python3/bin/pytest [root@cb8e397d5308] # ln-s / var/jenkins_home/python3/bin/pytest / usr/bin/pytest.

Preface selenium runs on a windows machine and starts the interface every time, which is very unstable. So the thought of using chrome to come to the headless interface-free mode, is indeed a lot of convenience. In order to improve the efficiency and stability of automation, the selenium automation environment is deployed to the linux server, which is more convenient. Environment: centons 7.6 python 3.6 chrome 77.0.3865.90 chromedriver 77.0.3865.40 selenium 3.14

Method 1 to install the latest version of chrome: download it locally and install it

First download the latest version of google-chrome 77.0.3865.90

Wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

After the download is complete, install the local package using yum

Yum localinstall google-chrome-stable_current_x86_64.rpm

Method 2: yum installs yum install google-chrome-stable_current_x86_64.rpm online

Or specify an address

Yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm

After the installation is complete, check the next version number

> google-chrome-version Google Chrome 77.0.3865.90chromedriver driver downloads the chromedriver driver, and the historical version http://npm.taobao.org/mirrors/chromedriver finds the corresponding driver version

You can download the zip package using wget

Wget http://npm.taobao.org/mirrors/chromedriver/77.0.3865.40/chromedriver_linux64.zip

Extract the zip package. If prompted that there is no zip, install yum-y install zip first.

Unzip chromedriver_linux64.zip # decompress zip

After decompression, move chromedriver to the / usr/bin/ directory

Mv chromedriver / usr/bin/

View the chromedriver version number

> chromedriver-- version ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217 refsMaqqqxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx) install selenium install the latest version of selenium 3.141.0

Pip3 install selenium

[root@yoyo chrome] # pip show selenium Name: selenium Version: 3.141.0 Summary: Python bindings for Selenium Home-page: https://github.com/SeleniumHQ/selenium/ Author: UNKNOWN Author-email: UNKNOWN License: Apache 2.0 Location: / usr/local/python3/lib/python3.6/site-packages Requires: urllib3 Required-by: [root@yoyo chrome] # run selenium code to create a new test_demo.py file and run the test code

From selenium import webdriver from selenium.webdriver.chrome.options import Options chrome_options = Options () chrome_options.add_argument ('--headless') # Interfaceless chrome_options.add_argument ('--no-sandbox') # solves the problem of no error in DevToolsActivePort files chrome_options.add_argument ('--disable-gpu') # disables GPU hardware acceleration. If the software renderer is not in place, the GPU process will not start. Chrome_options.add_argument ('--disable-dev-shm-usage') chrome_options.add_argument ('--window-size=1920,1080') # sets the width and height of the current window driver = webdriver.Chrome ('chromedriver',chrome_options=chrome_options) # driver = webdriver.Chrome () driver.get ("https://www.cnblogs.com/") print (driver.page_source) driver.quit () run the code

Python3 test_demo.py

Print out the results normally, indicating that the success above is all the content of this article "how to install Selenium in Linux system". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report