MicroFocus / leanft-selenium-java-sdk

LeanFT Java SDK for Selenium - LeanFT for Selenium Java SDK extends the Selenium WebDriver API with locators and utilities that enable creating tests which are more robust, and reduces Selenium test automation and maintenance efforts.
Apache License 2.0
11 stars 4 forks source link

Utils.snapshot not getting correct image if page moves using Utils.highlight or Utils.scrollIntoView #5

Open panama69 opened 6 years ago

panama69 commented 6 years ago

The below code sample where I opened a chrome browser on CentOS machine and set the window to a specific size to replicate the issues I have reported along with this one.

Notice that I am even re-finding the element after the Utils.hilight in case coordinate weren't correct after things scrolled a bit.

The snapshot should be capturing the price $1,009.00 from http://www.advantageonlineshopping.com/#/category/Tablets/3

System.setProperty("webdriver.chrome.driver", "./2.36/chromedriver");
ChromeOptions co = new ChromeOptions();
co.addExtensions(new File("/opt/leanft/Installations/Chrome/Agent.crx")); // path to agent on my linux yours may differ
co.addArguments("disable-infobars");
WebDriver driver = new ChromeDriver(co);
driver.manage().window().setSize(new Dimension(945, 850));

...

we = driver.findElement(new ByEach(
        By.tagName("a"),
        By.visibleText(Pattern.compile("\\$1,00\\d\\.\\d\\d"))
        ));

Utils.highlight(we, 2000);

we = driver.findElement(new ByEach(
        By.tagName("a"),
        By.visibleText(Pattern.compile("\\$1,00\\d\\.\\d\\d"))
        ));

snapshot = Utils.getSnapshot(we);

Verify.areEqual ("$1,009.00", we.getText(), "Price Verification","Verify price displayed matches price expected", snapshot);