不能在 Linux (debian) 机器上调用 chromedriver


Resources: VM -Debian Linux , Selenium 4 , Chrome V78, ChromeDriver , Jenkins , Maven, JAVA 8
**Issue:** I can not invoke chromedriver on Linux (debian) machine.
I can see message "Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code."
on Jenkins.
Maven command : clean install test
Log Trace:::

[詹金斯远程处理能力]===>通道已启动 正在执行 Maven: -B -f/var/lib/jenkins/workspace/Maven/pom.xml 全新安装测试 [信息]正在扫描项目... [警告] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile( @ Land ---

[INFO] Changes detected - recompiling the module!
[INFO] Compiling 8 source files to /var/lib/jenkins/workspace/Maven/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:3.0.0-M3:test (default-test) @ Land ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running TestSuite
[INFO ] 2019-09-18 21:51:26.644 [main] BaseClass -     [32mINFO[m - Creating Screenshot folder for this current execution.
directory is  : /var/lib/jenkins/workspace/Maven/screenshots
directory is exist /var/lib/jenkins/workspace/Maven/logs
directory is exist /var/lib/jenkins/workspace/Maven/test-output
[INFO ] 2019-09-18 21:51:26.655 [main] SetUpTest -     [32mINFO[m - ============================================================    
[INFO ] 2019-09-18 21:51:26.655 [main] SetUpTest -     [32mINFO[m - ====== Initializing Driver, Starting Browser Session =========    
[INFO ] 2019-09-18 21:51:26.655 [main] SetUpTest -     [32mINFO[m - ============================================================    
projectPath is: /var/lib/jenkins/workspace/Maven    
[INFO ] 2019-09-18 21:51:26.656 [main] BaseClass -     [32mINFO[m - projectPath is: /var/lib/jenkins/workspace/Maven    
[INFO ] 2019-09-18 21:51:26.656 [main] BaseClass -     [32mINFO[m - Driver value is : null    
[INFO ] 2019-09-18 21:51:26.656 [main] BaseClass -     [32mINFO[m - chrome driver is here
Starting ChromeDriver 78.0.3904.11 (eaaae9de6b8999773fa33f92ce1e1bbe294437cf-refs/branch-heads/3904@{#86}) on port 4878
Only local connections are allowed.
**Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.**
[INFO ] 2019-09-18 21:51:27.930 [main] SetUpTest - 
[INFO ] 2019-09-18 21:51:27.930 [main] SetUpTest -  ============ createAccount Test case is Started. ==============
[INFO ] 2019-09-18 21:51:27.931 [main] SetUpTest -  
[INFO ] 2019-09-18 21:51:27.932 [main] TestListener  - 
[INFO ] 2019-09-18 21:51:27.933 [main] TestListener  - ===== createAccount - Test case is Skipped =======
[INFO ] 2019-09-18 21:51:27.934 [main] TestListener  - 
[INFO ] 2019-09-18 21:51:27.934 [main] TestListener  - ===== createAccount - Test case is Failed =======
[INFO ] 2019-09-18 21:51:27.941 [main] BaseClass -  ******** Disposing Browser Driver **********    
[INFO] Tests run: 0, Failures: 0, Errors: 0, Skipped: 0    
[INFO]    
[ERROR] There are test failures. This is the final result
----------------------------------------------------------------
**My code :**

这是我的硒代码:

if (browserName.equalsIgnoreCase("chrome")) {
System.setProperty("webdriver.chrome.driver",  "/usr/bin/chromedriver");
ChromeOptions options = new ChromeOptions();
options.addArguments("--verbose");
options.addArguments("--whitelisted-ips=''");
options.addArguments("--disable-extensions");
options.addArguments("--disable-notifications");
options.addArguments("disable-infobars");
options.addArguments("--incognito");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--disable-gpu --disable-software-rasterizer");
options.addArguments("--disable-gpu-sandbox");
options.addArguments("--disable-features=VizDisplayCompositor");

这些是我到目前为止在chromedriver上尝试过的选项

driver = new ChromeDriver(options); // This line is not being invoked successfully.
------------------------------------------        
What I tried so far:
1. I tried firefox browser - which is not launching as well
2. I tried to "chmod 777" files, drivers and folders as per requirement
3. I set up few chrome "options.addArguments" to "disbale GPU" , "headless"  and "no sandbox" as per google
4. I looked in VM that if there are already multiple instance opened for Chromedriver via "htop" and other commands to kill the older sessions but I did not see any chrome because it's never been launched
5. https://stgconsulting.com/running-automated-selenium-tests-from-jenkins-on-linux/
6.  https://tecadmin.net/setup-selenium-chromedriver-on-ubuntu

资源: Maven, Chrome,ChromeDriver, Linux(Debian(, Java, Testng, jenkins

我遵循的基本Linux(Debian(设置的链接:https://stgconsulting.com/running-automated-selenium-tests-from-jenkins-on-linux/

在解决方案之前,我们一直看到以下错误

[信息] 2019-09-20 09:41:19.341 [主] 基类 - 浏览器名称值为 : 铬 [信息] 2019-09-20 09:41:19.341 [主要] 基类 - 铬驱动程序在这里 在端口 29688 上启动 ChromeDriver 78.0.3904.11 (eaaae9de6b8999773fa33f92ce1e1bbe294437cf-refs/branch-heads/3904@{#86}( 仅允许本地连接。 请保护 ChromeDriver 和相关测试框架使用的端口,以防止恶意代码访问。 [信息] 2019-09-20 09:41:23.904 [主要] 设置测试 - ==================================================================== [信息] 2019-09-20 09:41:23.904 [主要] 设置测试 - =========== 创建帐户测试用例已启动。


解决方案后,我没有看到失败/错误,并且我能够在Linux(Debian(上执行:

[信息] 2019-09-20 08:46:30.675 [主要] 基类 - 铬驱动程序在这里 在端口 9770 上启动 ChromeDriver 75.0.3770.140 (2d9f97485c7b07dc18a74666574f19176731995c-refs/branch-heads/3770@{#1155}( 仅允许本地连接。 请保护 ChromeDriver 和相关测试框架使用的端口,以防止恶意代码访问。 [1568994392.814][警告]:此版本的 ChromeDriver 尚未在 Chrome 版本 76 中进行测试。 2019-9-20上午8:46:33 org.openqa.selenium.remote.ProtocolHandshake createSession 信息:检测到的方言:W3C [信息] 2019-09-20 08:46:33.227 [主要] 基类 - 浏览器是铬


解决方案步骤和信息:

(1(您可以在包装盒上安装最新的Chrome Linux浏览器

(2(https://chromedriver.chromium.org/downloads 到这里,对ChromeDriver版本进行暴力破解

(3(我正在使用Chrome linux 77(截至2019年9月20日(和Chrome驱动程序76.0.3809.25,为我工作

(4( "请保护 ChromeDriver 和相关测试框架使用的端口,以防止恶意代码访问" - 防火墙一无所获

(5( 检查您的 Chmod 777 Chrome 驱动程序权限

这是一个浏览器和CHROME驱动程序误码,您需要做的就是检查兼容性

相关内容

  • 没有找到相关文章

最新更新