Help me create dynamic selector

Hi all, hope all of you are doing good.

I was playing with dynamic selectors, but I realized it’s very tough to do because “IDx” will interfere if we make couple of changes.

Let’s say for example here I want to click on this ad(just an example, disable adblocker to see it, or incognito)

If I use this strict selector it is working

<webctrl id='aswift*' tag='IFRAME' parentclass='adsbygoogle adsbygoogle-noablate' src='https://googleads*' css-selector='body&gt;ins&gt;div&gt;iframe' idx='2' />
<webctrl tag='*' />

But suppose the ad format changes to texts from banners, the selector is changing as well, but it shouldn’t change cause the position of the ad is same and it’s fixed.

Like here the ad format changes to text like this, it doesn’t work anymore:

The selector changed to this:

<webctrl id='aswift_5' tag='IFRAME' />
<webctrl parentid='banner-eta-vanilla' tag='DIV' />

This is the website I am testing on the example:

https://hitmarketing.nl/

Do you have any solution for cases like this? Also, are we supposed to use strict selector when it comes to dynamic selector or fuzy? Thanks in advance.

P.S: I am doing it on Firefox

@Tejaa

After little observation we can see that the dynamic selector might not work

instead what you can do is to use find children activity and get the last child of the advertisement aria-label so that you get the requried bottom advertisement always

Use find children with below as the filter…and in element indicate whole window

<webctrl aria-label='Advertisement' tag='DIV' />

then you get last element by uielementoutput.Last

this element is the whole bottom window…now from the bottom window if you need to click then just use click on it as by default it clicks on center you dont need to get to exact advertisement

if you want to get to it as well then make observations of what you might find in the different attributes and which attribute can be sued for filtering and getting the right element

In the initial case making a css selector is the only one which is making it unique no use of id class etc as they are same across all advertisements

In the later case selector is changing because the type of advertisement is different…try to correlate the ui changes to selectors then you can get at a better selector or a way around

Hope this helps

cheers

1 Like

HI Anil, Thanks for your effort and time. I tried to implement it, but it’s not clicking on the uielementoutput.Last like you said. See if I am doing it rightly:

This is the properties section of Find Children Activity:

@Tejaa

ins cope try with descendants

cheers

1 Like

Wow. now it seems to work. Only problem is that it is only taking Hardware events or windows message clicks, not taking simulate clicks, where as simulate is working on other parts of the site. I seem to miss something. Can you please check?

@Anil_G Sometimes getting this weird error on the click activity, any idea what it could be due to:

image

@Tejaa

Try using sumilate…looks like the element you are trying to click is not visible on screen

cheers

1 Like

I see. Simulate click seems to disappear the error but the click is not happening in real. I even tried Simulate with delay before and windows-message with delay before.

Here is the workflow:
Test.xaml (12.2 KB)

@Tejaa

made few changes like input mode…added an activate,and maximize window in use applciation/browser…It worked…try the same

Test.xaml (13.2 KB)

Also input mode window messages is also working

I changed the app to chrome in use application selector as I dont have firefox…you can change back if needed

cheers

1 Like

If you’re getting idx in the selector you need to modify the selector - by using additional properties - so that it doesn’t need idx. You should avoid idx in your selectors.

<webctrl tag='*' />

This isn’t a valid selector. It will match literally anything. You have to learn to add properties from UI Explorer to modify selectors and make them unique. To make a selector dynamic you’d replace a value in the selector with a variable, not with *

Hi. Thanks again. I tried it, but sadly it’s not accurate as well. Failing 90% of the time

I have an idea. Is it possible to make clicks based on outgoing URLs? For example when I hover over the ads, it always starts with https://adclick.g.doubleclick.net/

So can we search for outgoing urls and based on that we can click on any url that starts with the above url? Is that possible on UiPath?

@Tejaa

Then please add that in the selector to identify the add and click…the problem is every add will have same url not only the bottom one…

Also can you say what is the error?basic idea is to refine the selector and move forward

Cheers

1 Like

Thanks, Anil. There’s no error actually, it’s showing as success but the click isn’t happening sometimes.

And yes you are right, every ad will have the same URL not only the bottom one. But I am fine even if it clicks any one URL out of them, not specifically the bottom. Is that doable? How do I set it up in that case?

And thank you so much for your continuous response and effort, I really appreciate, you are one such a gem. :slightly_smiling_face:

@Tejaa

Then in the find children just use the filter with the url …that should work

Or just use selector like this

<webctrl href='baseurlhere*' />

If not href use src that also might work

Cheers

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.