How to differentiate between two elements if they have same attribute

I have a scenario in which i have to click on refresh button every time whenever status changed to completed from In Progress. But the all attributes of Completed and In Progress are same because they are in the same position only text changed. How to differentiate between them.

@nutan feel free to use the WebAutomation.GetDetailsOfElement action to retrieve element’s ‘innerText’ property.

Please refer to this example:

#Script waits until the 'innerText' element attribute changes 
#from 'Hello' to 'Swapped text!'

WebAutomation.LaunchChrome \
Url: 'https://www.w3schools.com/howto/howto_js_toggle_text.asp' \
WindowState:WebAutomation.BrowserWindowState.Normal \
ClearCache:False ClearCookies:False \
BrowserInstance=> Browser

label Retry_Until

WebAutomation.GetDetailsOfElement BrowserInstance: Browser\
Control: 'domcontainer{<{<{<SelectorSeparator>}>}>}uia3:// div[id="myDIV"]'\
AttributeName: 'innerText' AttributeValue=> AttributeValue

Console.Write Message: AttributeValue

if AttributeValue <> 'Swapped text!' then
WebAutomation.PressButton BrowserInstance: Browser\
Control: '''domcontainer{<{<{<SelectorSeparator>}>}>}uia3://
button:contains("Toggle Text")'''
goto Retry_Until
end

image

3 Likes

@jokoum, another great one. Every time you post I learn something new.

This doesn’t relate to the OP’s request really, but thanks to this post, I was able to replace

WebAutomation.ExecuteJavascript BrowserInstance:  Browser \
                                Javascript:'function ExecuteScript() { document.querySelector(\'div.container.page:nth-child(5) div.row:nth-child(5) \
                                div.col-xs-10.col-xs-offset-1.col-sm-4.col-sm-offset-4 div.form-group div.editor-label > button.btn.btn-primary\').click(); }' \
                                Result=> Result

with

WebAutomation.PressButton       BrowserInstance:  Browser\
                                Control: 'domcontainer{<{<{<SelectorSeparator>}>}>}uia3:// button:contains("Sign In")'

in a script I’ve been working on all day.
Regards,
burque505

2 Likes