Am using selenium webdriver 2.210 + JAVA for testing.I have a sample code for selecting all mails in gmail.But the code throws an \"Element is not currently visible and so m
Here is a summary of things you can do to tackle the problem (examples in Protractor/Javascript):
maximize the browser window (on Chrome+Mac, currently you have to do it differently):
browser.driver.manage().window().maximize();
verify that there are no other elements matching the locator. You can get this error if there is an another element matching the locator that is actually invisible.
wait for the element to be clickable:
var EC = protractor.ExpectedConditions,
elm = element(by.id("myid"));
browser.wait(EC.elementToBeClickable(elm), 5000);
scroll into view of the element:
var elm = element(by.id("myid"));
browser.executeScript("arguments[0].scrollIntoView();", elm);
click via javascript:
var elm = element(by.id("myid"));
browser.executeScript("arguments[0].click();", elm);
move to element and click via "browser actions":
var elm = element(by.id("myid"));
browser.actions()
.mouseMove(elm)
.click()
.perform();
Try to downgrade selenium webdriver to 2.20.0.
I got similar error with ruby gem version 2.21.0 and 2.21.2.
In my case web driver always return button.visible? = false
in case of button is added to the page via .Ajax call.
My tests work previously for a longer time and nothing related has changed. So I assume this is a bug in the current version of webdriver.
If you application uses jQuery, you may do the clicks using Javascript. I created this simple helper for clicking elements that WebDriver refuses to find:
public static void jqClick(String selector, JavascriptExecutor driver) {
driver.executeScript("$('" + selector + "').click()");
}
As the "driver", you can use, for instance a org.openqa.selenium.firefox.FirefoxDriver
.
This was the only solution that worked for me.
Selenium will not interact with WebElements that are hidden or that are not displayed to the user. In this case, it's not unusual for user clicks to interact with a div element or something similar which in turn triggers the actual button, which is hidden for visual purposes. I'd suggest running through the steps in the selenium IDE in firefox on your page. See if multiple events are triggered when you perform the click on your "hidden" element. In the case that multiple events are in fact triggered, follow suit in your WebDriver code.
Alternatively, you can use the JavascriptExecutor class provided in Selenium. After you do that, you can execute any JavaScript to manipulate the DOM on a Web page.
Ref:: http://selenium.googlecode.com/svn/trunk/docs/api/java/org/openqa/selenium/JavascriptExecutor.html
In my case (PhantomJSDriver called from Selenium WebDriver in c#) I had to set the Window Size to be large enough for the element to be visible:
driver.Manage().Window.Size = new Size(1000, 800);
I discovered that workaround reading through the issues here: https://github.com/ariya/phantomjs/issues/11637