public void ECM_20245() throws Exception {
String org = null;
checkout = new CommonCheckoutModule();
mini = new MiniCartModule();
orderAction = new OrderActionsModule();
ShoppingCartModule cart = new ShoppingCartModule();
orderHist = new IntelligoStoreOrderHistoryLandingModule();
order = new OrderHistoryLandingModule();
org = ConfigurationLibrary.BuyingForData.get("Buy_InvoiceStore");
OrgSelectorModule select = new OrgSelectorModule();
String roleA = ConfigurationLibrary.prop.getProperty("ECCROLE_ADMIN_STORE");
OrderConfirmationModule confirm = new OrderConfirmationModule();
checkout.buyingForMyself();
checkout.checkoutSingleIndividualCertificationPrdOrg();
mini.validateMiniCart().viewCartClick();
cart.validateShoppingCartPage();
cart.getGrandTotalPriceFromCart();
cart.ClickProductFromShoppingCart();
mini.clearCart();
select.orgBuyingFor(org);
checkout.SingleIndividualCertificationoption();
mini.validateMiniCart().viewCartClick();
cart.validateShoppingCartPage();
cart.checkoutSelection();
confirm.chooseOrgFromConfirmation(org).selectConfirmation();
checkout.enterPurchaseCodeForStore().selectInvoiceAndSubmit();
checkout.orderSuccessValidation();
String orderId = order.getOrderIDFromOrderConfirmationPage();
orderHist.ctaLinkValOrderActivationPageForIC();
CommonLibrary.newBrowserLaunch();
ConfigurationLibrary.loginForAllEnv(roleA, "UserId1");
orderAction.orderSearchInAdmin(orderId).storeOrderDetailsValForOrg();
}
上面代码中CommonLibrary.newBrowserLaunch();启动新浏览器并执行一组代码。Testng aftermethods 关闭最新打开的浏览器,但不关闭现有浏览器。我无法使用 driver.quit 因为 Testng 执行将并行.. 两个浏览器实例都可以关闭吗? (可以用@aftermethods关闭)
设置 windowHandles = driver.getWindowHandles();
// Iterate through the window handles and close each window
for (String windowHandle : windowHandles) {
driver.switchTo().window(windowHandle);
driver.close();
}
您可以尝试上面的代码来关闭所有打开的窗口