Here is my method to click the element:
public void clickGallery(String show) {
StringBuilder sb = new StringBuilder();
sb.append("//a[starts-with(@href, '/");
sb.append(show);
sb.append("/gallery/')]");
String xpath = sb.toString();
isElementXpathPresent(xpath); // for debugging this returns true
WebElement element = driver.findElement(By.xpath(xpath));
element.click();
And the HTML on the page:
<div class="content-wrapper">
<ul class="menu" style="width: 3000px; position: relative; left:
0px;">
<li>
<div class="gallery">
<div title="title" class="media_thumbnail gallery_thumbnail">
<a href="/show/gallery/more">
</div>
</div>
And the error:
org.openqa.selenium.ElementNotVisibleException: Element is not
currently visible and so may not be interacted with
System info:
os.name: 'Linux', os.arch: 'amd64', os.version:
'2.6.32-27-generic', java.version: '1.6.0_22'
Driver info: driver.version: RemoteWebDriver
Now I can run the isElementPresent command and it is there, here is
that method:
protected boolean isElementXpathPresent(String xpath) {
try {
driver.findElement(By.xpath(xpath));
return true; // Success!
} catch (NoSuchElementException ignored) {
return false;
}
}
What am I missing here? Why is the element "not visible"? Now there
are multiple xpaths on the page that would match, but I am assuming it
would just pick the first as this same general method has been
successful in other places.