Reputation: 187
i am currently working on selenium webdriver. The issue is that when i select some options of the first multi select on my page, the code crashes when i am about to select the next multi select. Can anyone help me regarding this issue. The code that i am using for multi select is:
driver.findElement(By.xpath("(//button[@type='button'])[2]")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-0")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-1")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-2")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-3")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-4")).click();
The next multi select also has the same kind of code with the different element. Looking forward to some sort of a good solution. Thanks.
Upvotes: 0
Views: 1014
Reputation: 26
The code you've shown clicks to open the dropdown list, then clicks to select some options. It never clicks to close the dropdown list, so I suspect it's being left open. If your next dropdown list is then hidden by the first one, Selenium won't be able to click it.
Try repeating the first line of your code at the end which, so it becomes:
driver.findElement(By.xpath("(//button[@type='button'])[2]")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-0")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-1")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-2")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-3")).click();
driver.findElement(By.id("ui-multiselect-estimatorToolMultiselect-option-4")).click();
driver.findElement(By.xpath("(//button[@type='button'])[2]")).click();
Upvotes: 1