web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Matching browser UI el...
Power Automate
Unanswered

Matching browser UI element to variable, case insensitive

(2) ShareShare
ReportReport
Posted on by 22

Hi

I'm trying to click on a UI element that matches a variable, but due to inconsistencies I need it to be case insensitive.

The element in question is this:

 

<span class="k-in">Adam Smith<input id="useritem" name="useritem" type="hidden" value="9"></span>

 

This works apart from the case sensitivity: 

 

div[Id="display-userhierarchy"] > div > ul > li > ul > li > div > span:contains(%UserFullName%)

 

Courtesy of some searching, I've found that the following works where the only issue is case, but I'm not overly happy with it as I'm likely to have other issues that would be better solved e.g. with regex instead.

(I also can't find references to the WA_ functions and am concerned that they are deprecated and exist only as backwards compatibility with Windows Automate?)

 

div[Id="display-userhierarchy"] > div > ul > li > ul > li > div > span:WA_SimpleTextEqualsIgnoreCase(%UserFullName%)

 

 So, is anyone able to help me to do it with regex? I realise that I'll need to use i as the for case insensitivity, but can't work out what the syntax should be to use regex here.

Note that the text I'm searching for isn't the title or similar attribute, and it isn't so much regex itself that's the problem as to how to implement in this situation, ie the .net regex to match the span is simply "adam smith"i , I just don't know how to incorporate it!

 

Thanks in advance for any help!

 

Jonathan

I have the same question (0)
  • subhaveera Profile Picture
    20 on at

    Did 

    WA_SimpleTextEqualsIgnoreCase

     work for you? I have to build a selector that will look for exact match of inner html text inside a <div> element. contains("%variable%") works. But, in my case there are multiple matches that will succeed with contains... So, I want an exact match. 

    WA_SimpleTextEqualsIgnoreCase

     seems to be the solution. But i cant find any documentation or anyone who has used it successfully? Is it deprecated? If, so what is the new replacement for it?

  • JonathanR Profile Picture
    22 on at

    Hi

    It's working ok, but like you say, there appears to be no information readily available. As you can see, no-one ever replied

     

    Jonathan

     

  • subhaveera Profile Picture
    20 on at

    It works?

     

    I have to build a custom selector in power automate desktop that will look for exact match of a string (case-insensitive) within the inner text of element <div>. 

     

    html > body > div:eq(1) > div:eq(0) > div > div > form > div:eq(3) > div:eq(0) > div:eq(1) > div:eq(1) > div > div > div:eq(2) > div > ema-imo-diagnosis-select-ce > ng-select > ng-dropdown-panel > div > div:eq(1) > div:contains("%CurrentImpression.Name%") >div:contains("%CurrentImpression.icd10%")

     

    that is my current selector. But it matches multiple items. I want to match exactly the same string. WA_SimpleTextEqualsIgnoreCase - seems to be the solution. But it is not working. Is it deprecated? If so, what is the new one? Or, how can I match the exact string within inner text? 

     

    I have tried using div[innnerText=%variable%], Text, Label, Title etc... only contains works, but it matches more that one. Do you know of any solution?

  • JonathanR Profile Picture
    22 on at

    As I said, it works for me. Have you tried it? 

    html > body > div:eq(1) > div:eq(0) > div > div > form > div:eq(3) > div:eq(0) > div:eq(1) > div:eq(1) > div > div > div:eq(2) > div > ema-imo-diagnosis-select-ce > ng-select > ng-dropdown-panel > div > div:eq(1) > div:WA_SimpleTextEqualsIgnoreCase(%CurrentImpression.Name%) >div:WA_SimpleTextEqualsIgnoreCase(%CurrentImpression.icd10%)

  • subhaveera Profile Picture
    20 on at

    Thanks so much Jonathan!! Actually I have been trying exactly the same for 2 days.. Now that, you said confidently that it works for you, I looked closely and found there was a space appended in the inner html text, which I was missing in my variable and that's why it didn't match!! That's so silly.. Sorry for the trouble.. Thanks again.

  • subhaveera Profile Picture
    20 on at

    Ignore my previous reply.. unfortunately, it didn't match even after adding spaces 😞

    subhaveera_1-1708487004002.png

    Attached screenshot of the content, I am trying to match. What am I doing wrong here? I have tried giving with/without spaces, with/without quotes... It just doesn't find the match at all.. I tried this:

     

    html > body > div:eq(1) > div:eq(0) > div > div > form > div:eq(3) > div:eq(0) > div:eq(1) > div:eq(1) > div > div > div:eq(2) > div > ema-imo-diagnosis-select-ce > ng-select > ng-dropdown-panel > div > div:eq(1) > div:contains("%CurrentImpression.Name%") >div:WA_SimpleTextEqualsIgnoreCase(%CurrentImpression.icd10%)

     

    Still, it doesn't match at all... If, I replace WA_SimpleTextEqualsIgnoreCase with contains, it immediately matches. But, it matches more than one.

  • JonathanR Profile Picture
    22 on at

    My first thought is to check whether the whitespaces are actually the space character or not - this has caused me issues in the past when for some reason a website used a different character. As it was inconsistent I ended up reading the list into an array, looping and removing all whitespace, then indexing against it. This may not be the best way, but it worked.

     

    For reference, this is my selector that works fine on a normal list:

    div[Id="display-userhierarchy"] > div > ul > li > ul > li > div > span:WA_SimpleTextEqualsIgnoreCase(%UserFullName%)

  • subhaveera Profile Picture
    20 on at

    Finally I figured it out.. Posing the result here, so that it will help someone..

     

    The selector that worked:

    html > body > div:eq(1) > div:eq(0) > div > div > form > div:eq(3) > div:eq(0) > div:eq(1) > div:eq(1) > div > div > div:eq(2) > div > ema-imo-diagnosis-select-ce > ng-select > ng-dropdown-panel > div > div:eq(1) > div >div:WA_SimpleTextEqualsIgnoreCase(" %CurrentImpression.Name% [%CurrentImpression.icd10%] ")

     

    Selector that will never work:

    html > body > div:eq(1) > div:eq(0) > div > div > form > div:eq(3) > div:eq(0) > div:eq(1) > div:eq(1) > div > div > div:eq(2) > div > ema-imo-diagnosis-select-ce > ng-select > ng-dropdown-panel > div > div:eq(1) > div:contains("%CurrentImpression.Name%") >div:WA_SimpleTextEqualsIgnoreCase(%CurrentImpression.icd10%)

     

    That is because, the <div> that is last but one, contains the text of its child <div> appended to it!!!! So, when we try to do exact match of the first string alone, it will fail as our variable contains only half of the text. So, keep in mind, when doing full equal match, we have to match it with its child elements' texts concatenated.

     

    Thanks Jonathan for your inputs!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard