Wednesday, 15 August 2012

javascript - Java Selenium 2.0 - handle z-index (navi) when using builtin scroll before WebElement .click() -


Selenium 2.0. Click () with automatic scrolling until the element is not visible and it is allowed to click on:

  WebAngel box = driver.fix element (BID (box idid) ); Box.click ();  

It usually works fine, Selenium will scroll until the box appears and then clicks ().

Anyway it org.openqa selenium. WebDriver Exposure If an element containing high z-index is present. This scrolls the element, but due to the low Z-index it is not visible. In my case, a navigation bar at the top of the page.

I thought of solving it at the top of the page with the javascript scroll, so the element would appear at the bottom of the page, but this can not be the best (or even a good) solution. .

  JavaScript Expert JS = (JavaScript Extractor) driver; // Scroll to Top will make the box on the bottom of the page jse.executeScript ("scroll (0, -10000);");  

Is there a great way to handle it through a whole test suite without a hack like Javascript scroll?

  string scripts = string Format ("$ ('. Item-Container'). ScrollTo ($ ('Li #% s'))", currentId);  

To run your script with this script, you must have CSS or Xpath


No comments:

Post a Comment