Selenium按钮提交/单击不会从chrome Web驱动程序重定向到成功页面

时间:2017-06-08 14:00:20

标签: java html5 selenium-webdriver chrome-web-driver

在从一个页面导航到另一个页面时,我遇到了Selenium的问题。

以下是代码。如果我点击下面的元素,jQuery图像将打开,直到下一页加载。但它并没有导航到下一页本身。图像继续旋转,窗口将关闭。为什么呢?

我收到NoSuchElementFoundException

Chrome版本: 58.0.3029.110

driver.findElement(By.name("continue")).click();

@Test
public void executeLoginApp() throws InterruptedException {
    driver.navigate()
            .to("url with login application");
    WebElement userName = driver.findElement(By.id("uname"));
    WebElement pwd = driver.findElement(By.id("passwd"));
    userName.sendKeys("test");
    pwd.sendKeys("test");
    Thread.sleep(2000);

    javaScriptExecutor.executeScript("window.scrollTo(0, document.body.scrollHeight)");
    Thread.sleep(2000);
    //driver.findElement(By.xpath("//input[@name='continue']")).click();
    //Thread.sleep(1000);
    //driver.manage().timeouts().implicitlyWait(50, TimeUnit.SECONDS);
     driver.findElement(By.name("continue")).click();
    //signOn.click();   
        callYourInformation();
}

private void callYourInformation() {
    /*try {
        Thread.sleep(5000);
    } catch (InterruptedException e) {

        e.printStackTrace();
    }
    WebDriverWait wait = new WebDriverWait(driver, 10);
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    String previousURL = driver.getCurrentUrl();
    ExpectedCondition e = new ExpectedCondition<Boolean>() {
          public Boolean apply(WebDriver d) {
            return (d.getCurrentUrl() != previousURL);
          }};
        wait.until(e);}*/
       // currentURL = driver.getCurrentUrl();
    if (driver.getCurrentUrl().contains("yourinfo")) {
        // testing yourinfo page
        WebElement emailAddress = driver.findElement(By.id("emailAddress"));
        emailAddress.clear();
        emailAddress.sendKeys("selenium@wwwmail.com");
        WebElement addressLine1 = driver.findElement(By.id("addressLine1"));
        addressLine1.clear();
        addressLine1.sendKeys("New york");
        WebElement grossAnnualIncome = driver.findElement(By.id("grossAnnualIncome"));
        grossAnnualIncome.sendKeys(String.valueOf(6000));
                    WebElement submit = driver.findElement(By.id("submitApplication"));
        submit.click();
        driver.findElement(By.id("Continue")).click();
    }
     else{
     do other logic.
     }

我尝试了一切但没有运气。注释行是我的尝试,但没有一行重定向到该页面。

0 个答案:

没有答案