252627282930313233
System.out.printf("forward to %s \n", secondUrl); dr.navigate().forward(); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
323334353637383940
WebElement menu = dr.findElement(By.id("dropdown1")).findElement(By.linkText("Another action")); (new Actions(dr)).moveToElement(menu).perform(); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
// ͨ��ul�ٲ㼶��λ dr.findElement(By.className("dropdown-menu")).findElement(By.linkText("watir-webdriver")).click(); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
414243444546474849
System.out.println(alert.getText()); alert.accept(); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
161718192021222324
System.out.printf("title of current page is %s\n", dr.getTitle()); System.out.printf("url of current page is %s\n", dr.getCurrentUrl()); System.out.println("browser will be close"); dr.quit(); } }
282930313233343536
WebElement current_page = dr.findElement(By.className("pagination")).findElement(By.className("active")); System.out.printf("Current page is %s\n", current_page.getText()); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
272829303132333435
// 获取该链接的text System.out.println(link.getText()); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
Alert alert = dr.switchTo().alert(); alert.accept(); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
424344454647484950
List<WebElement> allCheckboxes = dr.findElements(By.cssSelector("input[type=checkbox]")); allCheckboxes.get(allCheckboxes.size() - 1).click(); Thread.sleep(1000); System.out.println("browser will be close"); dr.quit(); } }
111213141516171819
System.out.println("maximize browser"); dr.manage().window().maximize(); Thread.sleep(2000); System.out.println("browser will be close"); dr.quit(); } }