使用Selenium Web Driver Java

时间:2016-06-23 20:05:45

标签: javascript java selenium selenium-webdriver modal-dialog

我正在使用Selenium Web Driver来测试应用程序,但我遇到了问题。 问题是,我有一个模态对话框,必须打开另一个模态对话框,但当我调用第二个模态对话框时,selenium在同一个窗口中打开第二个。 遵循代码:

公共类NewContract {

public static void main(String[] args) throws InterruptedException {

    WebDriver driver = new FirefoxDriver();

    ................
    Using this code to not stop the Selenium Web Driver
    ((JavascriptExecutor) driver).executeScript("window.showModalDialog = window.open;"); 

    //clicking on the next steps will open the new contract pop-up window
    driver.findElement(By.xpath(".//*[@id='bs-example-navbar")).click();

    // Switch to new window opened
    for(String winHandle : driver.getWindowHandles()){
        driver.switchTo().window(winHandle);
    } 

    // New Contract Windows 
    //Switch to Iframe
    driver.switchTo().frame("compContentFrame");  

    ..............
    Using this code to not stop the Selenium Web Driver
    ((JavascriptExecutor) driver).executeScript("window.showModalDialog = window.open;"); 

    //Click Select Template
    driver.findElement(By.id("SelectTemplateButton:img")).click();

    }

}

我的问题是:如何使用selenium web驱动程序打开2个模态对话框? First Modal Opened Second overwrites the first

0 个答案:

没有答案
相关问题