三、TestNG 数据驱动注解,可配合Grid支持多node机器,多浏览器同时运行脚本
public class GridTest2 {
/
设置数据驱动数据
/
@DataProvider(name = "data_1")
public Object[][] test1(){
return new Object[][]{
{"firefox","http://192.168.1.105:8888"},
{"chrom","http://192.168.1.105:5555"}
};
}
/* 调用数据驱动数据,并判断数据进行对应的Grid创建,支持不同浏览器在不同node跑脚本 */ @Test(dataProvider = "data_1") public void testProvider(String browser,String url) throws MalformedURLException { DesiredCapabilities dc = null; if (browser.equals("firefox")){ dc=DesiredCapabilities.firefox(); }else if(browser.equals("chrom")){ dc=DesiredCapabilities.chrome(); }else { System.out.println("DataProvider.name.data_1,未包含该驱动"); } WebDriver driver = new RemoteWebDriver(new URL("http://192.168.1.105:5556/wd/hub"),dc); driver.get("http://www.baidu.com"); }
}
相关推荐
ITstudied 2020-05-06
cintmain 2020-04-20
86427019 2019-12-21
SolitudeSky 2019-12-09
wugang0 2019-12-09
lucialee 2019-11-08
mohanzb 2019-10-22
mrjianghaijun 2015-07-30
chengzhezhijian 2015-06-24
pengzhanxuan 2012-11-14
不忘初心才能始终 2019-07-01
80487608 2015-07-29
石羊 2019-06-30
aduocd 2019-06-30
mrsuddenflash 2013-11-18
libra0 2019-06-29