I have a button I want to click, Selenium isn't giving me an error just stops. I've tried both xpath and css and it just stops.

<a ng-click="login();" ng-disabled="loginForm.$invalid || submitting == true" ng-class="submitting == true ? 'm-progress' : ''" class="btn btn-primary btn-lg btn-block pink button" tabindex="4">sign in</a

This is the code for the button. And these are the two attempts I've tried:


Or with CSS:


I am new to selenium so I could be doing it wrong. Any advice would be appreciated.


1 Answer 1


Try this xpath

//*[contains(@class,'btn btn-primary btn-lg btn-block pink button') and contains(@tabindex,'4')]

The xpath basically means : any element that has class attribute containing 'btn btn-primary btn-lg btn-block pink button' and a tabindex attribute containing 4.

You should try to read a little about how to write custom xpaths as addons like Firepath are not always useful in case of dynamic web application/pages testing

  • Thanks this worked, Interestingly enough my original syntax works, I just had to do it twice.
    – Christian
    Commented Oct 20, 2016 at 18:44
  • 2
    Glad to know this worked. The reason why your xpath may have not worked in the first run is either your application is dynamic and position of elements keep changing or the element had not loaded during your first run. If it was due to the later, I would recommend you add driver.manage().timeouts().implicitlyWait(60,TimeUnit.SECONDS) after declaring driver to ensure driver waits and tries to locate the element for 60 seconds if element is not found/loaded Commented Oct 20, 2016 at 18:57

Your Answer

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

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