Jenkins 在自动化测试中无法找到 Chrome 浏览器 – 我可以做什么?

huangapple go评论75阅读模式
英文:

Jenkins is failing to find Chrome browser for automated tests - what can I do?

问题

I'm trying to start to run my tests in Jenkins using Java + Selenium + TestNG. For example, I'm trying to get the title of google.com. In my IDE, everything works correctly, my code is in Git, Jenkins starts and compiles the project. To ensure that everything is correct, my simple method prints some text, and it works. ChromeDriver was started successfully.

But the WebDriver (Chrome Driver) encounters this problem image issue.

I've searched everywhere for a solution, and everyone says to make sure that the Chrome browser and WebDriver version are the same. It is correct; the versions are the same.

I think the WebDriver can't find the Chrome browser:

"The process started from the Chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed."

How can I run the test with WebDriver or how can I specify the path to Chrome browser for the WebDriver?

I would be grateful for any help. Thanks and have a good day!

stacktrace 1
stacktrace 2

英文:

I'm trying to start to run in Jenkins my tests
java + selenium+ TestNG
for exemple Im try to get title on google.com
In my IDE all work correct, my code in git, jenkins starting, compile project
To sure that all correct my simple method print some text, its work
ChromeDriver was started successfully.

but webdriver (chrome driver) get this problem image issuge

Im search issue every were says make sure thats Chrome browser and webdriver version the same. it correct version is the same

Im think that webdriver can't find to chrome browswer:

> "The process started from chrome location /usr/bin/google-chrome is
> no longer running, so ChromeDriver is assuming that Chrome has
> crashed.) "

How can I run test with webdriver or how to show for webdriver path to Chrome browser?

I will be grateful for any help
Thanks and have a good day!
stacktrace 1
stacktrace 2

答案1

得分: 1

Great!
Murat Ishen 谢谢你!
它起作用了

ChromeOptions opt = new ChromeOptions();
    opt.setBinary("/usr/bin/google-chrome-stable");  //在此指定了Chrome二进制文件的位置
    
    opt.addArguments("--headless");
    opt.addArguments("--no-sandbox");
    driver = new ChromeDriver(opt);
英文:

Great!
Murat Ishen Thank You!
it is works

ChromeOptions opt = new ChromeOptions();
    opt.setBinary("/usr/bin/google-chrome-stable");  //chrome binary location specified here
    
    opt.addArguments("--headless");
    opt.addArguments("--no-sandbox");
    driver = new ChromeDriver(opt);

huangapple
  • 本文由 发表于 2023年6月1日 12:50:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/76378745.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定