如何将弹出窗口作为网页处理并同时发出警报?

时间:2016-08-02 04:35:47

标签: selenium selenium-webdriver selenium-chromedriver

I am not able to fill this form and also not able to handle the alert obtain on top left corner

请帮我填写此表格,然后进入网站并处理警报。

这是我的代码无效:

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();

        }
}

1 个答案:

答案 0 :(得分:1)

在身份iframe的{​​{1}}内的website弹出窗口中,您需要切换iframe_Login,然后才能找到弹出窗口的关闭按钮,如下所示: - < / p>

iframe

希望它有所帮助.. :)