I am getting below exception on performing mouse over operation and trying to click on subelement.Mouse over is happening but clicking on subelement(submenu) is not happening and throwing the following exception.Can any one help on this.

Exception in thread “main” org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with
Command duration or timeout: 20.08 seconds
Build info: version: ‘2.44.0’, revision: ’76d78cf’, time: ‘2014-10-23 20:03:00’
System info: host: ‘ZSPL-330’, ip: ‘172.16.4.48’, os.name: ‘Windows 7’, os.arch: ‘x86’, os.version: ‘6.1’, java.version: ‘1.6.0_21′
Session ID: 804a8fcf-e14e-4298-b2af-90e1dbf6c77f
@googlecode.com/components/command-processor.js:548:5)

code snippet for which above exception is occuring:

WebDriver driver = new FirefoxDriver();

driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

driver.get(“http://rsa.qa.local:8887/web/guest/home”);

driver.findElement(By.xpath(“//input[contains(@name,’login’)]”)).clear();
driver.findElement(By.xpath(“//input[contains(@name,’login’)]”)).sendKeys(“admin@rsa.qa.local”);

driver.findElement(By.xpath(“//input[contains(@name,’password’)]”)).sendKeys(“1234”;abc”);

driver.findElement(By.xpath(“//input[contains(@value,’Sign In’)]”)).click();

Actions builder = new Actions(driver);

WebElement programs = driver.findElement(By.xpath(“//li/a[text()=’Programs’]”));

//    WebElement programStudio = driver.findElement(By.xpath(“//li/a[text()=’Program Studio’]”));

//Move cursor to the programs

builder.moveToElement(programs).perform();

//Give 5 sec for submenu to be displayed

Thread.sleep(10000);

//   driver.findElement(By.xpath(“//li/a[text()=’Program Studio’]”)).click();

driver.findElement(By.xpath(“//li[contains(@id,’programMgmTab’)]”)).click();

driver.close();

Train Asked on November 18, 2014 in Selenium WebDriver.

hi
builder.moveToElement(programs).build().perform();   // try with this once

on November 18, 2014.

Hi ankit,

Thanks for u r response.I tried with the above statement as suggested by you ,now the eclipse is not throwing any exception but  click  operation on sub menu is not happening.I mean mouse over is happening but click on sub menu is not happening.Can you please throw a light  on this….

Thanks
Praphul

on November 18, 2014.

make sure that your xpath for submenu element is correct

on November 18, 2014.

yea ankit  the xpath is correct,if not it should have thorwn exception(NotElementfound) right?
When i traverse through the source code(through fire bug) it is diable,i mean it is blurred.Is there any workaroud for this problem.Is  it to be handle through javascriptExecuter.If yes can you please post any sample code snippet.Thanks in Advance.

Regards
Praphul

on November 18, 2014.

try after removing that thread.sleep(); once

on November 18, 2014.

and yes using javascript we can do that but it should be working in this way too

on November 18, 2014.

yes i tried still it is not working

on November 18, 2014.

Ankit,

Can you please guide me how to handle mouse over operation using Javascript.If you  post any code snippet or any link demonstrating  mouseover operation would be helpful.

Thanks
Praphul

on November 18, 2014.
Add Comment
  • 1 Answer(s)

    Hi,

    Sometimes browser reacts weirdly. I suggest you to try the same code with other browser as well. I did face the same issue a long time back, it was working fine with one browser and getting failed with other browser.

    Second possible solution is try clicking on the Main Menu and then tries hitting the sub menu. May be the sub menus are not populating with mouse hover.

    Third, as you mentioned above after using build() that exception is not coming anymore, it means selenium is able to locate the element but not able to click. try below code:

    Actions action = new Actions(driver);
    WebElement mainElement = driver.findElement(By.ID("XXXXXX"));
    action.moveToElement(mainElement).perform();
    WebElement subElement = driver.findElement(By.ID("XXXXXX"));
    action.moveToElement(subElement);
    action.click();
    action.perform();
    

    Regards,
    Lakshay Sharma

    Professor Answered on November 18, 2014.

    Hi Lakshay,Thanks for u r reply.As you said the same script is working  fine with Chrome browser.And i tried with the second solution given in the  above answer but still it didnt works in firefox.In the below code i performend click on main menu(programs) then i moved to the  submenu and click on it. Would there be any compatible issue between selenium 2.44  and Firefox  ?33.1.1

    WebDriver driver = new FirefoxDriver(); //try{ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);driver.get("http://rsa.qa.local:8887/web/guest/home"); driver.manage().window().maximize();driver.findElement(By.xpath("//input[contains(@name,'login')]")).clear(); driver.findElement(By.xpath("//input[contains(@name,'login')]")).sendKeys("zymeadmin@rsa.qa.local");driver.findElement(By.xpath("//input[contains(@name,'password')]")).sendKeys("1234';Zyme");driver.findElement(By.xpath("//input[contains(@value,'Sign In')]")).click();Actions builder = new Actions(driver);WebElement programs = driver.findElement(By.linkText("Programs"));programs.click(); // builder.moveToElement(programs).perform();driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);WebElement programStudio = driver.findElement(By.linkText("Program Studio"));// Thread.sleep(5000);builder.moveToElement(programStudio);builder.click();builder.perform();driver.close();

    on November 19, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.