WinAppDriver icon indicating copy to clipboard operation
WinAppDriver copied to clipboard

How to identify an element when there is more than 1 instance exist with the same object properties

Open dillibabu123 opened this issue 7 years ago • 3 comments

I need to click an Link element when there is more than 1 instance exist with the same object properties. When using inspect tool it is showing same properties for both instance of link object. How to click on 1 of the 2 instances of link object.

Actually in UFT tool we can identify using index property like 0,1, 2 like this then it is identify and click respective instances but in WinAppDriver how to handle this. Please find the screenshot. SameObject_DifferentInstance

dillibabu123 avatar Sep 14 '19 14:09 dillibabu123

It can be handled the same way in WAD also. using index property var names = session.findelementbyAccessiblityID("automationID") names[index].click()

anunay1 avatar Sep 16 '19 07:09 anunay1

The question probably relates to which of the two you should work with. use FindElementsByX and get them all.

If you need to distinguish between the two, WinAppDriver probably can't

DLightstone avatar Sep 16 '19 19:09 DLightstone

I am able to handle this scenarios with below code. Thanks guys for your suggestions.

IList HPLink = App_Session.FindElementsByXPath(".//Text[@Name='N:JAMES,EDWARD']"); HPLink[0].Click(); HPLink[1].Click();

string Acttext_1 = HPLink[0].GetAttribute("Name"); string Acttext_2 = HPLink[1].GetAttribute("Name");

dillibabu123 avatar Dec 21 '19 09:12 dillibabu123