2
String strPrimaryNav = "MEN";
String strSecondaryNav = "Shoes";
String strTertiaryNav = "Golf";

driver.findElement(By.linkText(strPrimaryNav)).click();

WebElement weSecNav = driver.findElement(By.className("secondaryButton").linkText(strSecondaryNav));

Mouse mouse = ((HasInputDevices) driver).getMouse();
mouse.mouseDown(((Locatable)weSecNav).getCoordinates());
//just trying with for loop as the tertiary popup disappears quickly and hence getting ElementNotVisible Exception
for (int i = 0 ; i< 2; i++){
    mouse.mouseDown(((Locatable)weSecNav).getCoordinates());
    //mouse.mouseMove(((Locatable)weSecNav).getCoordinates(), 0, 0 );
    //WebElement weTerNav = driver.findElement(By.className("tertiaryButton").linkText(strTertiaryNav));
    WebElement weTerNav = driver.findElement(By.linkText(strTertiaryNav));
    boolean isSecDisplayed = ((RenderedWebElement)weTerNav).isDisplayed();
    System.out.println("isDisplayed: " + isSecDisplayed);
    System.out.println(" " + ((RenderedWebElement)weSecNav).getAttribute("href"));
    System.out.println(" " + ((RenderedWebElement)weSecNav).getValueOfCssProperty("action"));
    weTerNav.click();
}

I was trying the below code using selenium 2 but, the tertiary popup not stays long to click it and hence getting ElementNotVisible exception at Tertiary click.

Gerwald
  • 1,549
  • 2
  • 18
  • 42
Bhavana
  • 95
  • 3
  • 5
  • How long is the element supposed to be visible? I guess what I'm getting at is, why is Seleinum not clicking it in time? What is delaying Selenium from clicking it? In my experience, that happens really fast. – Katie Kilian May 12 '11 at 17:15

1 Answers1

0

You can at least check that the element is visible before you send your click:

Selenium s = new WebDriverBackedSelenium( driver, URL );
s.waitForCondition( "!( document.getElementById('.....') === null )", "20000" );
s.click( .... );

This avoids the exception. I'm not sure there is a way to make the popup stay any longer than it should.

Mike Kwan
  • 24,123
  • 12
  • 63
  • 96