java - Facing issue while clicking dropdown button using selenium webdriver code -


the application using having several dropdown buttons having same xml code. below code similar dropdown buttons.

<button class="btn dropdown-toggle bs-placeholder btn-default" role="button" data-toggle="dropdown" type="button" data-id="invcontactlist" title="" data-original-title="nothing selected">

i have use below code click button

driver.findelement(by.xpath("//button[@data-toggle='dropdown']")).click(); 

using code application run once there after gives error as: org.openqa.selenium.elementnotvisibleexception: element not visible , may not interacted command. have removed browser cookies wont help.

can please me root cause , solution ?

you might need wait element :

webdriverwait wait = new webdriverwait(driver, 10); wait.until(expectedconditions.elementtobeclickable(by.xpath("//button[@data-toggle='dropdown']"))).click(); 

or

wait.until(expectedconditions.elementtobeclickable(by.xpath("//button[@data-id='invcontactlist']"))).click(); 

or

wait.until(expectedconditions.visibilityofelementlocated(by.xpath("//button[@data-toggle='dropdown']"))).click(); 

or

wait.until(expectedconditions.visibilityofelementlocated(by.xpath("//button[@data-id='invcontactlist']"))).click(); 

try @ end.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -