public class ConfirmTest { @Test public void clickConfirmUsingSelenium() { System.setProperty("webdriver.chrome.driver", "src/main/resources/chrome/chromedriver"); WebDriver webDriver = new ChromeDriver(); webDriver.get("http://localhost:63342/seleniumcapsules/html/upload.html"); webDriver.findElement(cssSelector("input[value='Need Confirm']")).click(); webDriver.switchTo().alert().accept(); } @Test public void clickConfirm() { Page page = CHROME.load("http://localhost:63342/seleniumcapsules/html/upload.html"); page.button(NEED_CONIRM).click(); page.accept(); } }
Thursday, June 12, 2014
handle alert and confirm
The following two tests demonstrate how to click "OK" on a confirm message box, the first method uses Selenium directly, the second one uses Selenium Capsules framework,
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment