@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']"));

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

enter image description here

1 Answer 1


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')]


//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')]


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.