嗨,我已经将我的硒脚本与Jenkins集成在一起,但我无法启动Chrome浏览器



我已经将我的硒脚本与詹金斯集成了构建((64位(和75版支持的Chrome驱动程序。

在詹金斯(Jenkins(我得到

开始Chromedriver 75.0.3770.90 (A6DCAF7E3EC6F70A194CC25E8149475C6590E025-REFS/branch-heads/3770@{#1003}( 在端口21983上,仅允许本地连接。请保护港口 ChromeDriver和相关的测试框架用于防止访问 恶意代码。测试运行:7,失败:1,错误:0,跳过:6,时间 经过:1.332 sec<<<<失败! - 在测试套件中 beforemethod(qa.vehicle_registration(时间:1.206 sec<<<< 失败!org.openqa.selenium.webdriverexception:未知错误: Chrome无法启动:异常退出(未知错误: DevToolSactivePort文件不存在((该过程从 Chrome Location/usr/bin/google-chrome不再运行,因此 Chromedriver假设Chrome已崩溃。(构建信息: 版本:'3.5.3',修订:'a88d25fe6b',时间: '2017-08-29T12:42:44.417Z'系统信息:主机: '管理员latitution-3480',ip:'127.0.1.1',os.name:'linux','linux', OS.ARCH:'AMD64',OS.Version:'4.15.0-52代',Java.version: '1.8.0_11'驱动程序信息:驱动程序:version:chromedriver遥控器 StackTrace:#0 0x55C60975B6E9

我尝试了以下代码,但仍然遇到同样的错误。

public class Google{
  WebDriver driver;  
  @BeforeClass
  public void beforeMethod() throws IOException, InterruptedException 
  {
      System.setProperty("webdriver.chrome.driver","/home/ashishtiwari/driver/chromedriver");
      ChromeOptions options = new ChromeOptions();
      options.setExperimentalOption("useAutomationExtension", false);
      options.addArguments("start-maximized"); // open Browser in maximized mode
      options.addArguments("disable-infobars"); // disabling infobars
      options.addArguments("--disable-extensions"); // disabling extensions
      options.addArguments("--disable-gpu"); // applicable to windows os only
      options.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
      options.addArguments("--no-sandbox"); // Bypass OS security model
      options.addArguments("--headless");
      options.addArguments("--disable-dev-shm-usage");
      driver = new ChromeDriver(options);
      driver.manage().window().maximize();
      driver.manage().deleteAllCookies();
         driver.manage().timeouts().pageLoadTimeout(utill.ashu, TimeUnit.SECONDS);
          driver.manage().timeouts().implicitlyWait(utill.sonam, TimeUnit.SECONDS);
    //http://tmsapp.xbees.in/#/dashboard
          driver.get("https://google.com");
    }
 }
  1. 我在使用Visual Studio Code中使用Selenium启动Chrome浏览器时遇到了同样的问题。我通过从项目中删除Chromedriver.exe解决了此问题,因为我创建了如此多的Chromedriver.exe文件。.exe文件在您的项目中。
  2. chromedriver.exe文件应为bin/debug/net5.0/chromedriver.exe。
  3. 如果您遵循上述步骤,则无需为Chrome驱动程序提供本地路径。

相关内容

最新更新