0

I've created a small script to go to reddit login page enter username and password. My last step is to click the Log In button but my xpath is unable to find it and click the button. I've tried various different ways but none seem to be working.

Below is what i've tried

 driver.findElement(By.xpath("//input[@type='submit']")).click();
    driver.findElement(By.xpath("//button[@class='submit']")).click();
    driver.findElement(By.className("submitButton")).click();

Below is what chrome inspect gives

 <button class="AnimatedForm__submitButton m-full-width" type="submit">     
            Log In        
      </button>

1 Answer 1

1

Use WebDriverWait() wait for elementToBeClickable() and following xpath.

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[contains(.,'Log In')]"))).click();

OR

new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//button[@class='AnimatedForm__submitButton m-full-width' and @type='submit']"))).click();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.