0

Logic provided in the while loop is not running even though the condition is met. This is the step definition file for selenium using cucumber.

@Then("checks for the title of the page")
public void checks_for_the_title_of_the_page() {

        String password1 = ""; 
        String title = driver.getTitle(); 
        System.out.println("Title of current page: " +title ); 
        System.out.println("I am right before control statement now" );
        while (title == "Amazon Sign In") {
            System.out.println("Contol is in while loop");  
            lg.getpassword().sendKeys(password1);
            String captchaVal1 = JOptionPane.showInputDialog("Please enter the captcha value:");
            driver.findElement(By.id("auth-captcha-guess")).sendKeys(captchaVal1); 
            driver.findElement(By.id("signInSubmit")).click();   
        }         
    }
supputuri
  • 13,644
  • 2
  • 21
  • 39
  • Can't see a problem with getting into the loop. Make sure you reevaluate `title` inside the loop, else it will be an infinite loop. – ou_ryperd Feb 08 '20 at 06:26
  • https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java. Use equals() instead of == – Grasshopper Feb 08 '20 at 07:32

0 Answers0