0

I'm using gauge and taiko for automation, The problem is I'm unable to use xpath for click command on taiko.

await click($("//button[@class='btn-primary'][contains(.,'+ Add New')]"));

await click($("//html/body/form/div[3]/div[4]/div[4]/div[2]/div/div[1]/div/button"));

await click($("//button[contains(@onclick,'Client360.prototype.OpenNewClientModal();')]"));

I have tried all of the above but getting the same error. "Custom selector not found.

  • Add the details about your question about what is the hierarchy of the page and what Xpath are you using. Is your XPath incorrect or you are getting non-desired element from the Xpath? – Nikhil Sahu Mar 14 '19 at 12:37
  • Don't tell us that you're unable to do something. Tell us what you tried and how it failed. Even if your approach was completely wrong, telling us what you attempted enables us to put you back on the right track. – Michael Kay Mar 14 '19 at 15:18
  • @NikhilSahu I have updated the code in the question. – Shahid Mehmood Awan Mar 15 '19 at 21:58
  • @MichaelKay I have updated the code in the question – Shahid Mehmood Awan Mar 15 '19 at 21:59
  • The XPath expressions are syntactically valid, so I guess for some reason they're not matching anything in the target document. – Michael Kay Mar 16 '19 at 10:26
  • This seems to be an issue with [taiko](https://github.com/getgauge/taiko). Could you please raise an issue? XPath selectors are supposed to work, and these seem like valid XPath expressions as mentioned by @MichaelKay – Srikanth Venugopalan Apr 05 '19 at 02:02
  • @ShahidMehmoodAwan Please add html snippet for which you are trying to use xpath and also provide complete js file code along with imports – Sameer Patil Aug 07 '19 at 12:33

1 Answers1

0

$() uses backticks() not double-inverted comma("). try changing ```await click($("//button[@class='btn-primary'][contains(.,'+ Add New')]"))``` to ```await click($(//button[@class='btn-primary'][contains(.,'+ Add New')]`))```.

Hope this helps!