cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TPDBS
Frequent Visitor

Check for two elements in web page

Hello!

 

So, at the moment PA desktop lacks directives for OR and AND. That can still be done (when checking for values on variables and things like that) by comparing everything on the first operand and then to "true" on the second one.

 

However, what if you need to check for two elements on the web page? I haven't been able to find how to build an expression sort of like

%Browser.Contains(UIElementButton0)%

or something like that.

 

Any workaround would be appreciated in any case.

 

Thanks in advance! 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @TPDBS 

I suggested working with nested If's statements because your original question mentions two elements.

With more than 2 elements, an idea is using variables as flags and then compare those variables within Case/Switch options.

For example, first you set the variables as result of existing elements:

1. 'If web page contains' element A then

2. 'Set variable' %FlagA% to 1

3. 'End' if 

4. 'If web page contains' element B then

5. 'Set variable' %FlagB% to 1

6. 'End' if

7. 'If web page contains' element N then

8. 'Set variable' %FlagN% to 1

9. 'End' if

and so on

Then, concatenate these variables into a new one:

10. 'Set variable' %Test% as %FlagA%%FlagB%%FlagN% (this gives you 111 or 101 for example)

At last, use Switch/Case to define situations and actions:

11. 'Switch', value to check= %Test%

12. 'Case' =110

13. (Your actions here)

14. 'Case =101

15. (Your actions here)

...    

 

View solution in original post

4 REPLIES 4
yasunm02
Solution Sage
Solution Sage

Hi @TPDBS 

Not sure if I got your question correctly, but if you need something like %Browser.Contains(UIElementButton0)%, you can start with 'If web page contains' conditional and select the web element you want.

Conditionals - Power Automate | Microsoft Docs

 

To emulate 'AND' and 'OR', work with nested conditionals. For example:

AND:

1. 'If web page contains' element A

2.     'If web page contains' element B

3.          [Actions if true+true]

4.     'End' if

5. 'End' if

OR:

1. 'If web page contains' element A

2.     Go to Actions  

3. 'Else'

4.     'If web page contains' element B

5.          Go to Actions

6.     'End' if

7. 'End' if 

TPDBS
Frequent Visitor

Hi @yasunm02 

 

Thank you for you answer. But yeah that's precisely what I'm trying to avoid. If you need to check 3 or 4 elements it becomes increasingly complicated.

Hi @TPDBS 

I suggested working with nested If's statements because your original question mentions two elements.

With more than 2 elements, an idea is using variables as flags and then compare those variables within Case/Switch options.

For example, first you set the variables as result of existing elements:

1. 'If web page contains' element A then

2. 'Set variable' %FlagA% to 1

3. 'End' if 

4. 'If web page contains' element B then

5. 'Set variable' %FlagB% to 1

6. 'End' if

7. 'If web page contains' element N then

8. 'Set variable' %FlagN% to 1

9. 'End' if

and so on

Then, concatenate these variables into a new one:

10. 'Set variable' %Test% as %FlagA%%FlagB%%FlagN% (this gives you 111 or 101 for example)

At last, use Switch/Case to define situations and actions:

11. 'Switch', value to check= %Test%

12. 'Case' =110

13. (Your actions here)

14. 'Case =101

15. (Your actions here)

...    

 

TPDBS
Frequent Visitor

Hi @yasunm02

Right, this is not ideal but it will work alright. Thank you!

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

Users online (3,858)