2

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

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

我得到一个NoSuchElementFoundException

铬版本: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.
     }

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

4

0 回答 0