1

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");   
Thread.sleep(5000);
comboplayer.findElement(By.name("DEF Rebound")).click();
AppSession.findElementByName(editPlayer2).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");   
Thread.sleep(5000);
comboplayerdef.findElement(By.name("DEF Rebound")).click();
AppSession.findElementByName(editPlayer3).click();

How do I select the name from the second box ?

First combo box selection

second combo box

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

1 Answer 1

1

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 and acknowledge you have read our privacy policy.