3

In uipath, how to click on a button by it's color for multiple times until the color changes?

Initially the color of the button is red and I want to click on it until it turned to green.

kwoxer
  • 3,734
  • 4
  • 40
  • 70
Gedion
  • 31
  • 2

3 Answers3

1

It totally depends on your website. You have 3 possibilities:

  1. Use the Color Detector
  2. Use the style attribute. You could as example do it in this way:

    • get the Attribute of the button
    • check if the style contains the color green
    • if not click the button again
    • if so break the while UiPath process
  3. Sadly there is no known way to me to directly access the styles without inline styling. So to solve this you would need to write your own C# code to achieve that.

kwoxer
  • 3,734
  • 4
  • 40
  • 70
1

Alternatively to the solutions presented by others, you may also use the "Image Exists" activity and configure it with the image of the green button. Finally, all you have to do is create a while loop, which clicks on the button until the output of the "Image Exists" activity is True.

To sum up:

  1. configure "Image Exists" activity to find green button image and output the boolean result to a variable exists;
  2. create a do while loop which tests the value of the variable exists in the condition;
  3. configure a "Click" activity to click the button;
  4. put the "Click" and "Image Exists" activities inside the loop

NOTE: Instead of the "Do While" activity, you may also use the "Retry Scope" activity to prevent an infinite loop solution (configure with a limited number of retries).

Testing360
  • 101
  • 10
0

Similar to what @Kwoxer said above

You could get the selector for the green button eg

<ctrl name='my button' colour='green' />

then get a generic selector that is independent of colour and will work for the button all of the time

<ctrl name='my button' colour='*' />

then you would do

while (not element exists(<ctrl name='my button' colour='green' />))
    click(<ctrl name='my button' colour='*' />)

that way, while the green button doesn't exist it will keep on pressing the button

Conor
  • 736
  • 1
  • 13
  • 33