I'm trying to run my tests on several browsers (Chrome, Edge, Firefox etc.)
I don't need them to run parallel, they can run one after one is finished. I'm using init browser at @before
and switch case to look for the browser in the XML config file ( getData
function).
@BeforeClass
public static void openBrowser() throws ParserConfigurationException, SAXException, IOException {
initBrowser(getData("BrowserType"));
mainWindowHandle = driver.getWindowHandle();
wait = new WebDriverWait(driver, Long.parseLong(getData("WaitTime")));
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
initExtentReport();
initElements();
}
public static void initBrowser(String browserType) throws ParserConfigurationException, SAXException, IOException {
switch (browserType.toLowerCase())
{
case "firefox":
driver = initFFDriver();
break;
case "ie":
driver = initIEDriver();
break;
case "chrome":
driver = initChromeDriver();
break;
default:
driver = initChromeDriver();
break;
}
driver.manage().window().maximize();
driver.get(getData("URL"));
driver.manage().timeouts().implicitlyWait(Integer.parseInt(getData("WaitTime")), TimeUnit.SECONDS);
}
However since the test go to check the XML to see what browser I have in the BrowserType
(XML)
<Pre>
Chrome
</Pre>
there is no way for me to run the test on several browsers. I need to change manually the browser in XML to do so.
Is there a way to do this with Junit? (I'm using Java in Eclipse.)
您可以为不同的浏览器分别创建多个XML。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.