How can i click on particular element as they have different position in next execution

I want to click on an element from the list but its position is always not same even its total number of elements not same too. I tried to getelementsofdetail by innertext,It get the value of the element . I tried that if innertext value is equal to myvalue then it click on that element but selectors of all elements of list are different.

1 Like

@nutan, I hope someone is able to answer your question, I’d love to see the answer as well.
Regards,
burque505

Hey @nutan. As long as you know the text of the list item you wish to click on, feel free to use dynamic selectors, specifically the :contains() one.

This post could be helpful.

1 Like

Thanks once again, @jokoum. I get the feeling that the WinAutomation UiSpy and the Robin UiSpy are growing closer (maybe I’m wrong). The information at this Softomotive page seems useful, though, for general principles if nothing else.

EDIT: After experimenting, I’ve found the following all work for accessing the ‘Edit’ control in Notepad, running the latest Robin update. I’m assuming similar techniques will work for ‘WebAutomation’.

(contains)
:desktop > window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[class*=""Edit""]
(starts with)
:desktop > window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[class^=""E""]
(id)
window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[id=15]
(id, alternate)
:desktop > window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[id=15]
(id starts with)
:desktop > window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[id^=1]
(id contains)
':desktop > window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[id*=1]' 

Regards,
burque505

The code I listed above led me to experiment with interpolating variables in selectors. This too just builds on @jokoum’s work.

Screenshot:

Code:

# ****************************************
# Using variables in selectors with Robin
# ****************************************
# In WinAutomation you can interpolate variables with %var% syntax.
# (See https://support.softomotive.com/support/solutions/articles/35000107376-building-ui-selectors-beginner-guide)
# Very handy!
# We can achieve a similar result in Robin in a different way.
#
# N.B. Recommended (probably indispensable) reading: https://forum.robin-language.org/t/making-dynamic-controls/168 (thanks, @jokoum!)
# This script uses v.0.9.2
# (I suspect this will be much more useful with 'WebAutomation' - I will post results after I experiment.)


# We set our variable to be "The automation ID of the Notepad edit control contains [...]", as follows:
set selectorVariable to 'edit[id*=1]'
# Start Notepad
System.RunApplication                       ApplicationPath:  "notepad.exe" \
                                            CommandLineArguments:'' \
                                            WorkingDirectory:'' \
                                            WindowStyle:System.ProcessWindowStyle.Normal \
                                            ProcessId=> ProcessId

#Now we'll interpolate our variable.
UiAutomation.FormFilling.PopulateTextField TextField:  ':desktop > window[name=""Untitled - Notepad""][process=""notepad""]' + \
                                           '{<{<{<SelectorSeparator>}>}>}uia3://  >' + selectorVariable \ 
                                           Text: """'Id contains' selector was used 
(':desktop > window[name=""Untitled - Notepad""][process=""notepad""]{<{<{<SelectorSeparator>}>}>}uia3://  > edit[id*=1]')

That's all, folks!                                
"""

# We'll view our handiwork
wait 5

# Kill our abused Notepad :)

Result:

Regards,
burque505

1 Like

I get the value of list by attribute ‘innertext’ so i put that value in innertext contains and check with focus where it highlighted but it focused all values of list.

Can you explain how can i do it and it not take value in list it takes it as string because if i want to display the value of first list with index 0 it shows only one character not full value of one line