如何使用maven pom在IE中运行测试

时间:2015-08-17 01:02:32

标签: java maven internet-explorer selenium

我正在尝试使用maven在Internet Explorer中以Java语言运行从Selenium IDE导出的测试。但无法在pom.xml中声明依赖项。我的POM文件:

<plugin>
...
<systemPropertyVariables>
        <webdriver.chrome.driver>${webdriver.chrome}</webdriver.chrome.driver>
        <webdriver.iexplorer.driver>${webdriver.iexplorer}</webdriver.iexplorer.driver>
</systemPropertyVariables>
</plugin>
...
<profile>
  <id>iexplorer</id>
  <properties>
    <env>local</env>
    <webdriver.iexplorer>C:\auto_tools\IEDriverServer.exe</webdriver.iexplorer>
    <user.username></user.username>
    <user.password></user.password>
    <grid2.hub></grid2.hub>
    <site.url>http://php4dvd.com.ua/</site.url>
    <browser.name>iexplorer</browser.name>
    <browser.version></browser.version>
    <browser.platform></browser.platform>
  </properties>
</profile>

我正在尝试使用下一个命令行在终端中运行测试:

  

mvn test -P iexplorer

作为回答我得到消息:

  

测试失败:     登录&gt; TestBase.init:38»无法识别的浏览器类型:iexplorer

在chrome中运行测试对我来说很好:

  

mvn test -P chrome

在firefox中,测试运行也...我在Internet Explorer上做错了什么?

============================================== < / p>

File file = new File("C:/auto_tools/IEDriverServer.exe");
    System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
    InternetExplorerDriver driver = new InternetExplorerDriver();

这个决定对我有用,但我需要使用pom.xml文件完全运行测试。

期待您的帮助!

由于

1 个答案:

答案 0 :(得分:0)

试试

<webdriver.iexplorer>C:/auto_tools/IEDriverServer.exe</webdriver.iexplorer>

在pom .xml文件中替换下面的上一行

<properties>
    <env>local</env>
    <webdriver.iexplorer>C:\auto_tools\IEDriverServer.exe</webdriver.iexplorer>
相关问题