我无法关闭“https://www.makemytrip.com/”网站上的以下窗口:
我尝试使用
alert
、notification
和子浏览器弹出窗口,但没有任何效果。
有人帮忙吗?
<iframe>
中,因此您必须:
Induce WebDriverWait所需的frameToBeAvailableAndSwitchToIt.
Induce WebDriverWait所需的elementToBeClickable.
您可以使用以下任一Locator Strategies:
使用cssSelector:
driver.get("https://www.makemytrip.com/");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe[title^='notification-frame']")));
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("i.we_close"))).click();
使用xpath:
driver.get("https://www.makemytrip.com/");
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.xpath("//iframe[starts-with(@title, 'notification-frame')]")));
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//i[@class='wewidgeticon we_close']"))).click();
浏览器快照:
您可以在以下位置找到一些相关讨论: