2

I am facing issues with Selenium when navigating from one page to another.

Below is the code. If I click on following element a jQuery image will open until the next page gets loaded. But it's not navigating to next page itself. The image keeps on rotating and window will close that. Why?

I am getting a NoSuchElementFoundException

Chrome Version : 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.
     }

I tried all the ways but no luck. Commented lines are my tries but none of them redirects to that page.

Vinod Sidiginamale
  • 241
  • 1
  • 5
  • 9

0 Answers0