0
@When("I click on sign in again")
    public void i_click_on_sign_in_again() {
    WebElement signin1  = driver.findElement(By.xpath("//a[@class='uitk-button uitk-button-medium uitk-button-fullWidth uitk-button-has-text uitk-button-primary']"));
        signin1.click();
    }

Xpath couldn't locate the element. What am I doing wrong?

enter image description here

1 Answer 1

0

Above xpath not working because there a new line after button and 'primary' is in next line

1. if only and only want to find via class attribute then:

//a[contains(@class,'uitk-button uitk-button-medium uitk-button-fullWidth uitk—button-has-text uitk—button-')][contains(@class,'primary')]

OR

//a[contains(@class,'uitk-button uitk-button-medium uitk-button-fullWidth uitk—button-has-text uitk—button-')]

  1. Try finding with text:

xpath = "//a[contains(text(),'Sign in')]

OR

xpath = "//a[contains(@href,'/user/signin')]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.