-1

I have a button:

 <button type="submit" class="btn btn-default btn-auth">Anmelden</button>

nightwatch doesn't find it these ways:

browser.waitForElementPresent('//button[@class="btn btn-default btn-auth"]', 5000); 
browser.waitForElementPresent('//button[contains(@class, "btn btn-default btn-auth")]', 5000); 
browser.waitForElementPresent('//button[text()="Anmelden"]', 5000); 
browser.waitForElementPresent('//button[contains(text(), "Anmelden")]', 5000); 

but it is found this way:

browser.waitForElementPresent('.btn.btn-default.btn-auth');

Why are the 4 commands above not working? I have to checkout for text() because I have multiple buttons with the same class.

Munchkin
  • 4,528
  • 7
  • 45
  • 93
  • Is it giving any error if you are using anyone of them ? – NarendraR May 17 '17 at 09:57
  • Just `× Timed out while waiting for element /button[contains(text(), "Anmelden")]> to be present for 5000 milliseconds. - expected "found" but got: "not found"` – Munchkin May 17 '17 at 10:21

2 Answers2

1

If you want to find element by XPath, instead of class/id try this:

browser.useXpath().waitForElementPresent('//button[contains(@class,"btn-auth") and contains(text(),"Anmelden")]', 5000); 
0

Use this xpath;

//button[.="Anmelden"]

jova
  • 31
  • 3