如何使用selenium webdriver处理地理位置pop

时间:2018-02-12 07:13:58

标签: selenium selenium-webdriver

如何处理Selenium WebDriver中的地理位置弹出窗口?

Geolocation popup

2 个答案:

答案 0 :(得分:0)

加载主页后,只需执行以下操作:

WebElement elem = FluentWait<WebDriver>(driver)
            .withTimeout(60, TimeUnit.SECONDS)
            .pollingEvery(1, TimeUnit.SECONDS)
            .ignoring(StaleElementReferenceException.class,
                    NoSuchElementException.class)
            .until(ExpectedConditions
                    .elementToBeClickable(By.xpath(".//*[@id='allow']")));
elem.click();

答案 1 :(得分:0)

启动Naukri.com然后使用以下代码:

    //For "Sure"
    new WebDriverWait(driver, 30).until(ExpectedConditions.presenceOfElementLocated(By.id("allow")));
    driver.findElement(By.id("allow")).click();