【发布时间】:2019-09-21 03:52:38
【问题描述】:
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:::
[JENKINS REMOTING CAPACITY]===>频道已启动 执行 Maven:-B -f /var/lib/jenkins/workspace/Maven/pom.xml 全新安装测试 [INFO] 正在扫描项目... [警告] [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 :**
这是我的 Selenium 代码:
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
【问题讨论】:
标签: selenium-webdriver selenium-chromedriver