Clicking the latest entry on a drop down menu

Hey there,

I am building a bot which needs to use an ID code to find a certain vehicle on an online portal. Each time, it should be clicking on the latest year, but I’m not entirely sure how to do this:

As you can see, using the entered ID, the bottom value (2023) is the latest value. How would I then be able to get the bot to click on this entry every time? Of course, this year value will be different every time and grow more and more as the years go on.

It is probably very easy for you pros, but I’m a noob :smiley: Thanks for your help.

Will you already know the year before searching? If so, try putting “45924 2023” into the search box.

Anyway, based on what you’ve shown you’d need to use For Each UI Element to loop through the selections, code some logic to find the one with the highest year value (which you can get with RegEx), and then click it.

No, the year will change each time unfortunately and entering a year after the ID cancels the results and won’t search :frowning:

The problem with the looping method is that the selectors on the portal are all over the place. When iterating through the selector codes, some are values for other things across the site (bad design!).

in general we would use find children to get all items (options) from drop down
then we evaluate the the found items e.g.

  • checking the attribute innertext and evaluate it on some conditions

in your case we can try to filter on option tag and innertext *{{Code}}* with variable within the filter selector, then evaluate the year part and calculate the latest year

Mentioned option is one of many options to solve the case

1 Like

If you use For Each UI Element, you don’t need to build selectors. It uses a filter and gets them as objects, then you reference the object (variable) for all your property reads, clicks, etc.

Ahh this sounds like what I need - thanks!

I’ve done so and the output looks like all the selector information for it, how would I then display this as the intertext to move onto the next stage?

It turns out that extracting the results as a data table was the most effective way of getting these results. The ‘Find Child’ wouldn’t work as this is not a drop down menu.

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