I am using win app driver tool to automate my application. I am automating a combo box selection . To click the combo box and select the name. But here my GUI has 4 combo box is there, in that 2 box has same name. so second box click action is not performing.

This is the code for first combo box, firstly it will click the combo box and select the name.

WebElement comboplayer=AppSession.findElementByAccessibilityId("CmbDefPlayer");   
comboplayer.findElement(By.name("DEF Rebound")).click();

This is the second combo box selection, here it won't click becasue of having same name.. when I command the fisrt code, it is showing nosuch element exception.

WebElement comboplayerdef=AppSession.findElementByAccessibilityId("cmbdefrebound");   
comboplayerdef.findElement(By.name("DEF Rebound")).click();

How do I select the name from the second box ?

First combo box selection

second combo box

  • you can save both web element in list , then ln loop just add click operation. Aug 6 '18 at 6:01

Lets say there are 4 combo boxes on your page. So you can get all the combo boxes in a list and click on your intended one e.g. -

List<WebElement> comboplayers = AppSession.findElementsByAccessibilityId("CmbDefPlayer");

and here if you want to click on second one then

comboplayers.get(1).findElement(By.name("DEF Rebound")).click();  // index 1 represent second combo box as index starts with 0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy