java - 在 Maven Selenium 项目的 TFS 中找不到 chromedriver 可执行文件

标签 java maven selenium tfs

在 TFS2015 中通过 Maven build(POM.xml) 运行我的 Java Selenium 测试时,出现错误。我知道错误是针对 chromedriver 可执行文件的,但不确定我应该给出什么路径。

当我运行 eclipse-D:\DATA\chromedriver_win32\chromedriver.exe 时,当前使用此路径 对于通过 TFS 运行,我应该做哪些更改?

此外,Maven 设置是在 TFS 中完成的,在 POM.xml 中我提到了所有依赖项。因此,对于 chromedriver.exe 我是否必须在 TFS 中进行一些额外的设置。请帮忙。

我遇到的错误是-

java.lang.IllegalStateException: The driver executable does not exist: D:\DATA\chromedriver_win32\chromedriver.exe
at com.google.common.base.Preconditions.checkState(Preconditions.java:585)

POM.xml如下-

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>Maven_demo</groupId>
  <artifactId>Maven_Project</artifactId>
  <version>0.0.1-SNAPSHOT</version>

  <name>Maven_Project</name>
  <url>http://maven.apache.org</url>


  <dependencies>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>3.11.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.apache.maven.plugins
                                    </groupId>
                                    <artifactId>
                                        maven-plugin-plugin
                                    </artifactId>
                                    <versionRange>
                                        [3.2,)
                                    </versionRange>
                                    <goals>
                                        <goal>descriptor</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
            <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
        </plugins>
    </pluginManagement>
  </build>
  <dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
        </dependency>
    </dependencies>
  </dependencyManagement>
</project>

最佳答案

在创建新的 ChromeDriver 实例之前,您可以尝试将以下代码添加到 Selenium 程序中:

System.setProperty("webdriver.chrome.driver",
            "C:\\chromedriver.exe");

如果上述解决方案不起作用,请尝试根据构建代理计算机上的 Chrome 浏览器版本下载/更改 Chrome 驱动程序。

有用的链接:

关于java - 在 Maven Selenium 项目的 TFS 中找不到 chromedriver 可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51149710/

相关文章:

maven - Liquibase 在单个 Maven 构建中多次执行变更集

java - 如何比较下拉选项与 Selenium WebDriver 中的 UI 选项是否匹配?

ruby - 在 Cucumber Ruby 中使用 Selenium ChromeDriver 在 W3C 模式下无法调用非 W3C 标准命令 (Selenium::WebDriver::Error::UnknownCommandError)

java - 查询线程执行情况

java - 无法将 JMenuItem 添加到 JPopupMenu 中的 JMenu

maven - Apache Maven 资源插件排除目录

java - 在路径 : dexpathlist 上找不到类

testing - Selenium Test Runner 和变量问题

java - 如何扩展 CassandraRepository

java - ObjectDB,写入字段值失败(错误363)