Karate Robot: Not able to click button using image

Viewed 181

enter image description hereI am using Karate robot for clicking a button using image. Below is my code:

  • robot { app: '^Chrome', highlight: true }
  • robot.input('OracleDriver')
  • delay(2000)
  • robot.click('delete.png')

Sometimes I am able to click delete button for delete.png but other times I am not. So facing this issue intermittently.

2 Answers

Yes, finding by image is indeed not very reliable and should be only used as a backup when normal windows locators don't work.

I have only the following suggestions:

  • find a windows locator that works. note that you can navigate from a known locator using someElement.parent.firstChild etc: https://github.com/intuit/karate/tree/master/karate-robot#element-api
  • try to standardize the resolution that works best
  • see if using OCR works better
  • contribute code to Karate to make this better
  • look for another solution

I tried clicking delete button by using it's class and it is very reliable, below is my code

  • waitFor('.icons8-delete-blue').click()

I also followed @Peter's suggestion (someElement.parent.firstChild) and it worked for me!, below is the code

  • waitFor('.modal-footer').children[0].click()

Thanks @Peter for the suggestion

Related