0

How do I click on the following button "OK" using XPath:

driver.findElement (By.xpath ("//button[@class='btn btn-primary crtBtn btn btn-default']");

Screenshot:

Screenshot

Bugs
  • 4,491
  • 9
  • 32
  • 41
  • What is the error? Check if the button is inside an iframe? – Grasshopper Nov 13 '17 at 15:31
  • Error no such element: Unable to locate element: {"method":"xpath","selector":"//button[@class='btn btn-primary crtBtn btn btn-default']"} there is no iframe. just a lightbox appear just after login – Taha Iqbal Nov 13 '17 at 15:40
  • Try below xpath: `By.xpath("//button[.= 'Ok']")` – Kuldeep Kamune Nov 14 '17 at 12:23
  • Also HTML has composite class, check this thread for composite class element [link](https://stackoverflow.com/questions/20361643/compound-class-names-are-not-supported-consider-searching-for-one-class-name-an) – Kuldeep Kamune Nov 14 '17 at 12:27

1 Answers1

0

Hello you can try this xpath :

.//button[@type='button']

Also put wait as Thread.sleep before clicking this element.

Jignesh
  • 31
  • 10