在TFS中找不到Maven Selenium Project的chromedriver可执行文件

时间:2018-07-03 08:15:45

标签: 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>

1 个答案:

答案 0 :(得分:1)

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

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

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

有用的链接: