1

Could you please help me? I have a button which I need to click on. Checking it in the console, the XPath of this button returns 2 elements and I need to click on the 2nd one. So, at least these 2 locators are returning correctly my button: ("//a[@href='/organization/createorganization']")[1] ("//*[text()='mybuttonText']")[1]

enter image description here

I´m trying to create an automated test using Karate.

  • def temp = locateAll("/a[@href='/organization/createorganization']")
  • match karate.sizeOf(temp) == 2
  • temp[1].click()

My problem is that the size of temp is always 0.That means it doesn't find the locator?! Why wouldn´t find the locator? I tried also to introduce a delay, sleep time, the result is always the same. I can see visually when running the test that it doesn't click on the button. I´ve tried with both XPaths that I mentioned above and other XPaths that I could have come up with, but I get always the same - 0. enter image description here

Please, do you have any ideas how to solve this?

Thanks a lot in advance.

Ina
  • 33
  • 1
  • 1
  • 4

1 Answers1

0

Sounds like your locator is wrong. There's no way to tell from the limited amount of info in your question.

But try this:

* def temp = locateAll("//a[@href='/organization/createorganization']")

Or use other options: https://stackoverflow.com/a/63894989/143475

If all else fails, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I realized I missed one "/" when posting the message , even I used the correct locator in my test. Either way, I tried again with the locator you mentioned and it seems that `locateAll()` is not working for me. I made a quick check using `locateAll()` for another test scenario and I get the same result - locator is not found. Aparently, I can´t find any locator using `locateAll()`. But it works just fine using `click()` on the locator. For now, I solved the problem using `click("//a[@href='/organization/createorganization']")`. – Ina Sep 15 '21 at 09:10