我正在尝试同时在不同的浏览器中运行测试用例,但在执行此操作时,Chrome浏览器正在打开,但数据未在同一个firefox浏览器打开时加载,数据也会加载。
例如:尝试打开gmail.com页面。
在testng.xml下面:
<test name="ChromeTest">
<parameter name="browser" value="Chrome" />
<classes>
<class name="website.Hello" />
</classes>
</test>
<test name="FirefoxTest">
<parameter name="browser" value="firefox" />
<classes>
<class name="website.Hello" />
</classes>
</test>
BaseTest代码:
public class BaseTest {
WebDriver driver;
@BeforeTest
@Parameters("browser")
public void setup(String browser) throws Exception{
//Check if parameter passed from TestNG is 'firefox'
if(browser.equalsIgnoreCase("firefox")){
//create firefox instance
driver = new FirefoxDriver();
}
//Check if parameter passed as 'chrome'
else if(browser.equalsIgnoreCase("chrome")){
//set path to chromedriver.exe You may need to download it from http://code.google.com/p/selenium/wiki/ChromeDriver
System.setProperty("webdriver.chrome.driver","D:\\DesktopFrameWork\\WatchableDesktop\\resources\\chromedriver_Windows.exe");
//create chrome instance
driver = new ChromeDriver();
// driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
driver.manage().deleteAllCookies();
}
else{
//If no browser passed throw exception
throw new Exception("Browser is not correct");
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
}