3

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 Answers2

2

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
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Hi Peter, Our dropdown values are not fixed, it will be a dynamic list as and when user created those entries. Is there any solution/suggestion for locating dynamic dropdown list? – Bibhuti Bhusan Sahoo Mar 25 '21 at 09:32
  • @BibhutiBhusanSahoo you should be able to get the values from the list and get the value by index. no other suggestions – Peter Thomas Mar 25 '21 at 10:12
1

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