在Jenkins中,驱动程序不是可执行错误,但在本地计算机(MacBook)中运行 [英] Driver is not executable error in Jenkins but its running in Local Machine (MacBook)

查看:52
本文介绍了在Jenkins中,驱动程序不是可执行错误,但在本地计算机(MacBook)中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MacBook.当我通过testing.xml文件运行测试时,我们的Jenkins服务器正在linux服务器中运行,但是所有测试类都在运行,但是当我运行Jenkins build时,它就无法运行 错误提示驱动程序不可执行

I am working on MacBook. Our Jenkins server is running in linux server when I running tests via testing.xml file all test classes are running but when I run Jenkins build its not getting run Error is saying driver is not executable

我已经在詹金斯创建了maven项目,并从bitbucket给出了该项目的回购网址

I have created maven project in Jenkins and give repo url of this project from bitbucket

有人帮我解决这个问题吗?

anyone help me to sort out this issue ?

    [INFO] Running TestSuite
java.lang.IllegalStateException: The driver is not executable: /var/lib/jenkins/workspace/TravelCenterSeleniumJenkinsIntegrationCMB/target/classes/chromedriver
    at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
    at org.openqa.selenium.remote.service.DriverService.checkExecutable(DriverService.java:150)
    at org.openqa.selenium.remote.service.DriverService.findExecutable(DriverService.java:141)
    at org.openqa.selenium.chrome.ChromeDriverService.access$000(ChromeDriverService.java:35)
    at org.openqa.selenium.chrome.ChromeDriverService$Builder.findDefaultExecutable(ChromeDriverService.java:159)
    at org.openqa.selenium.remote.service.DriverService$Builder.build(DriverService.java:355)
    at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:94)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
    at utils.TestApp2.openBrowser(TestApp2.java:59)
    at uk.TravelcCenter_Tests.Sports_Shows_Tests.setUp(Sports_Shows_Tests.java:21)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:134)
    at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:63)
    at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:348)
    at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:302)
    at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:695)
    at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:523)
    at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173)
    at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46)
    at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:816)
    at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.util.ArrayList.forEach(ArrayList.java:1259)
    at org.testng.TestRunner.privateRun(TestRunner.java:766)
    at org.testng.TestRunner.run(TestRunner.java:587)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:384)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:378)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:337)
    at org.testng.SuiteRunner.run(SuiteRunner.java:286)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1187)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1109)
    at org.testng.TestNG.runSuites(TestNG.java:1039)
    at org.testng.TestNG.run(TestNG.java:1007)
    at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
    at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
    at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
    at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:384)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:345)
    at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:126)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:418)

推荐答案

public static String osDetector() {
  String os = System.getProperty("os.name").toLowercase();
  if (os.contains("win") {
    return Windows;
  } else if(os.contains("nux") || os.contains("nix") {
    return Linux;
  } else {
    return "OtherOs";
  }
}

// under the openDriverMethod
ChromeOptions options = new ChromeOptions();
if (osDetector.contains("Windows") {
  System.setProperty("webdriver.chrome.driver", "driver folder path");
} else if(osDetector.contains("Linux") {
  System.setProperty("webdriver.chrome.driver", "driver folder path");
  //you need to add this one i guess!
  options.setBinary("/usr/bin/google-chrome");
}

这篇关于在Jenkins中,驱动程序不是可执行错误,但在本地计算机(MacBook)中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆