In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you an example analysis of how to build automated testing in CentOS 7.x environment: Headless chrome + Selenium + ChromeDriver. The article is rich in content and analyzed and described from a professional point of view. I hope you can get something after reading this article.
My company wants to use Selenium for high-performance automated testing. For stability reasons, we chose the linux environment instead of the Windows environment. At the same time, in order to pursue testing efficiency and de-UI, Chrome's Headless scheme is chosen. 1. Environmental description
CentOS version:
LSB Version:: core-4.1-amd64:core-4.1-noarch 2, latest version of Google-Chrome installation
If you install google-chrome above CentOS/RedHat 7, you can fully refer to https://intoli.com/blog/installing-google-chrome-on-centos/ 2.1to specify an online agent.
Because the server environment itself is isolated from the public network, you need to specify an agent to properly apply the yum tool. The proxy server we use is http://10.46.89.29:1087 (this process can be ignored on the Internet). Source / etc/skel/.bash_profile
one
Perform the curl test:
[root@seersitapp05] # curl-vo / dev/null-H'x Murray head talk all 'https://www.suning.com'-k * About to connect () to proxy 10.46.89.29 port 1087 (# 0) * Trying 10.46.89.29. % Total% Received% Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0000000--:-0* Connected to 10.46.89.29 (10.46.89.29) port 1087 (# 0) * Establish HTTP proxy tunnel to www.suning.com:443 > CONNECT www.suning.com:443 HTTP/1.1 > Host: www.suning.com:443 > User-Agent : curl/7.29.0 > Proxy-Connection: Keep-Alive > x-header-trace:all >
< HTTP/1.1 200 Connection established < * Proxy replied OK to CONNECT request * Initializing NSS with certpath: sql:/etc/pki/nssdb 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* skipping SSL peer certificate verification 0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 * Server certificate: * subject: CN=*.suning.com,ST=江苏省,L=南京市,O=苏宁云商集团股份有限公司,C=CN * start date: 11月 21 15:21:01 2016 GMT * expire date: 11月 21 15:21:01 2019 GMT * common name: *.suning.com * issuer: CN=WoSign OV SSL CA,O=WoSign CA Limited,C=CN >GET / HTTP/1.1 > User-Agent: curl/7.29.0 > Host: www.suning.com > Accept: * / * > x-header-trace:all > < HTTP/1.1 200 OK < Expires: Tue, 13 Mar 2018 11:35:57 GMT < Date: Tue, 13 Mar 2018 11:30:57 GMT < Server: styx < Content-Type: text/html; charset=UTF-8 < Transfer-Encoding: chunked < X-XSS-Protection: 1 Mode=block < X-Frame-Options: SAMEORIGIN < Last-Modified: Tue, 13 Mar 2018 11:27:06 GMT < Pragma: Pragma < Cache-Control: max-age=300 < X-Cache-Hits: 10 < Via: 1.1 Xcache_Suning_92 < X-Via: 1.1 gangdianxun22:9 (Cdn Cache Server V2.0), 1.1 luoshan90:1 (Cdn Cache Server V2.0) 1.1 lsh282:7 (Cdn Cache Server V2.0) < Connection: keep-alive < strict-transport-security: max-age=300 < 00 00 00 -:--:-- 0:00:02--:-- 0 {[data not shown] 100 179k 0 179k 00 28448 0--:-0:00:06-43278 * Connection # 0 to host 10.46.89.29 left intact 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 2.2 specify yum source
The server should specify an appropriate yum source to avoid the embarrassment of not finding some dependencies. .repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
one
two
Pay attention to select the repo address that you can access normally. Yum clean all operation is performed after saving.
[root@seersitapp05 ~] # yum clean all loaded plug-ins: fastestmirror is cleaning software source: base updates yum-cdCleaning up everythingCleaning up list of fastest mirrors 1 2 3 4 5 2.3 install google-chrome
According to https://intoli.com/blog/installing-google-chrome-on-centos/.com/install-google-chrome.sh | bash
one
The script automatically detects and downloads the dependency packages missing from the current version of the installation of chrome. This is shown in the following figure.
The final successful installation will show:
Successfully installed google-chrome-stable, Google Chrome 65.0.3325.146.
Check to see if there is a lack of dependency:
Ldd / opt/google/chrome/chrome | grep "not found" 1
The returned value is empty, which means that the problem of chrome dependency under CentOS is basically solved.
2.4 run chrome
Execute-chrome-stable-- no-sandbox-- headless-- disable-gpu-- screenshot https://www.suning.com/
one
However, there are still mistakes:
[0100/000000.311368:ERROR:broker_posix.cc (43)] Invalid node channel message
After climbing over the wall for a long time, I found that the solution was still lack of dependence:
Yum install\ ipa-gothic-fonts\ xorg-x11-fonts-100dpi\ xorg-x11-fonts-75dpi\ xorg-x11-utils\ xorg-x11-fonts-cyrillic\ xorg-x11-fonts-Type1\ xorg-x11-fonts-misc-y 1 2 3 4 5 6 7 eight
Solve it. Run 3 again, the latest version of Chromedriver installation
To match the chrome version of Google Chrome 65.0.3325.146, download the latest version of chromedriver 2.3.6 linux64 bit http://npm.taobao.org/mirrors/chromedriver/2.36/chromedriver_linux64.zip#. / chromedriver Starting ChromeDriver 2.36.540471 (9c759b81a907e70363c6312294d30b6ccccc2752) on port 9515 Only local connections are allowed.
one
two
three
Success! Version: '3.5.3mm, revision:' a88d25fe6baked, time: '2017-08-29T12Vera 42purl 44.417Z' System info: host:' seersitapp05', ip: '10.47.145.25mm, os.name:' Linux', os.arch: 'amd64', os.version:' 3.10.0-514.26.2.el7.x86room64' Java.version: '1.8.0161' Driver info: driver.version: ChromeDriver at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable (DriverService.java:192) at org.openqa.selenium.remote.service.DriverService.start (DriverService.java:178) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute (DriverCommandExecutor.java:78) at org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:646) at org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java At org.openqa.selenium.remote.RemoteWebDriver.startSession (RemoteWebDriver.java:237) at org.openqa.selenium.remote.RemoteWebDriver. (RemoteWebDriver.java:138) at org.openqa.selenium.chrome.ChromeDriver. (ChromeDriver.java:178) at org.openqa.selenium.chrome.ChromeDriver. (ChromeDriver.java:146) at com.suning.seer.node.api.impl.WebAPI.openNewWindowByChrome (WebAPI.java:181)... 18 common frames omitted Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:9567/status] to be available after 20009 ms at org.openqa.selenium.net.UrlChecker.waitUntilAvailable (UrlChecker.java:102) at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable (DriverService.java:187)... 27 common frames omitted
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
Note that other versions of chromedriver may lack dependencies and make up for what they lack. 4. Java environment installation
Download http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html|grep java rpm-qa from Oracle officially | grep jdk rpm-qa | grep gcj
one
two
three
If the installation can bulk uninstall all files with Java:
Rpm-qa | grep java | xargs rpm-e-- nodeps 1
Extract the downloaded jdk under the / opt directory:
Tar-xvf jdk-8u161-linux-x64.tar 1
Configure the JDK environment, open / etc/profile, and add the JAVA environment variable:
JAVA_HOME=/opt/jdk1.8.0_161 JRE_HOME=/opt/jdk1.8.0_161/jre CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binexport JAVA_HOME JRE_HOME CLASS_PATH PATH
When the setup is complete, exit vim, and then continue to enter the following instructions to refresh the environment variables:
Source / etc/profile
Try to test whether JAVA is installed successfully:
[root@seersitapp05 opt] # java-version java version "1.8.0mm 161" Java (TM) SE Runtime Environment (build 1.8.0_161-b12) Java HotSpot (TM) 64-Bit Server VM (build 25.161-b12, mixed mode) [root@seersitapp05 opt] # echo $JAVA_HOME / opt/jdk1.8.0_161 5, Tomcat 7 build
First, let's configure the environment variables and memory settings of tomcat. After entering the bin directory of tomcat, open the catalina.sh file with the vi command, and add the following configuration:
JAVA_OPTS= "- Xms512m-Xmx1024m-Xss1024K-XX:PermSize=512m-XX:MaxPermSize=1024m" export TOMCAT_HOME=/opt/tomcat-7.0.42 export CATALINA_HOME=/opt/tomcat-7.0.42 export JRE_HOME=/opt/jdk1.8.0_161/jre
Next is the application port number of tomcat. Enter the server.xml file in the conf directory of tomcat. The default is port 8080. 7.0.42/bin/startup.sh run
one
The startup console log can be printed in:
Tail-f-n 1000 tomcat-7.0.42/logs/catalina.out
Turn off tomcat:
Tomcat-7.0.42/bin/shutdown.sh
In addition, it also encountered the situation that the tomcat process still exists after the CentOS is shut down. In the production environment, of course, you can't kill the process every time.
Finally, if you turn on the agent mode, remember to restore the configuration and turn off the agent mode when the real server is running.
The above is the example of automated testing built under the environment of CentOS 7.x: Headless chrome + Selenium + ChromeDriver shared by Xiaobian. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.