My challenge involves a drop-down menu with changing options. I am looking to dynamically select the last item in this menu, without knowing the total number of items present.
I am seeking advice on using xpath for this feature. Specifically, I am using ui vision rpa kantu which is based on selenium xpaths.
Currently, I can select the first element using xpath (index=1, index=2, index=3) as shown below:
{
"Command": "select",
"Target": "xpath=//select[@name='sidebar-2_position']",
"Value": "index=1"
}
How do I go about selecting the last option in the drop-down menu when the total number of items is unknown? If only I could determine the total number of items available, it would help me solve this issue.
To tackle this problem, I need either:
-) an xpath that can select the last option regardless of the number of items
-) or a javascript solution to count the elements in my drop menu and then use an index=N approach