我有一个测试类,如果我在eclipse中运行,这个类的所有测试都运行正常.(右键单击该文件,以jUnit身份运行)但是当我尝试使用Ant脚本运行时,它会失败.
实际上这个测试是针对2个浏览器运行的.此测试对IE Chrome运行良好.它对IE运行良好.但测试无法对抗Chrome.我不确定发生了什么.我在项目路径的所有资源/驱动程序/下放置的所有驱动程序相关信息.浏览器配置文件我保存在项目的browserProfiles文件夹下.
我不确定为什么测试无法用于Chrome.
我已经附加了测试代码和我试图在源代码中创建webdriver和seldriver的代码.
package com.mytests;
public class MyParamTest {
private MyWrapperForBrowser browser;
@Before
public void setup(){
b = new MyWrapperForBrowser("chrome");
b.start();
}
@Test
public void testCURDOnEntity() {
MyEntity e = new MyEntity(browser);
Assert.assertTrue(e.createMessage("message", "text"));
// more business logic..
}
}
Run Code Online (Sandbox Code Playgroud)
和源代码
package com.mysrc;
import java.util.*;
import org.openqa.selenium.*;
public class MyWrapperForBrowser {
private final WebDriver webDriver;
private WebDriverBackedSelenium selDriver;
public MyWrapperForBrowser(String driver) {
if (driver.equalsIgnoreCase("IE")
{
// create webDriver , selDriver
}
else{
System.setProperty("webdriver.chrome.driver",
"allresources/drivers/chromedriver.exe");
DesiredCapabilities broserCapabilities = DesiredCapabilities.chrome(); …Run Code Online (Sandbox Code Playgroud)