請幫我填寫此表格,然後進入網站並處理警報。
這裏是我的代碼是不工作:
public class FirstCry {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "D:\\Selenium\\CP-SAT\\Chromedriver\\chromedriver.exe");
WebDriver a = new ChromeDriver();
a.get("http://www.firstcry.com/");
Thread.sleep(5000L);
a.manage().window().maximize();
String k = a.getPageSource();
System.out.println(k);
WebDriverWait Wait = new WebDriverWait(a, 30);
Wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(".//*[@id='amt']/div[2]/div[1]/div[1]/div[3]/div")));
WebElement b = a.findElement(By.xpath(".//*[@id='amt']/div[2]/div[1]/div[1]/div[3]/div"));
b.click();
}
}
你爲什麼不使用窗口句柄。 –
所有在單個窗口中打開。因此,沒有使用Windows處理程序 –
@KishanPatel嘗試更新的答案,它會處理您的彈出窗口和通知警報兩個..感謝:) –