pazone / ashot

WebDriver Screenshot utility. Take screenshots, crop, prettify, compare
Other
637 stars 157 forks source link

Only able to take a screenshot when using just webdriver. #363

Open CalumR23 opened 1 year ago

CalumR23 commented 1 year ago

Hello I am trying to test out aShot and it only works when I use just webdriver. When trying the viewport scrolling: Screenshot myScreenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(100)).takeScreenshot(webDriver); I get the below error: java.lang.Exception: org.apache.commons.io.IOUtils.toString(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Ljava/lang/String; at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:27) at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getFullHeight(ViewportPastingDecorator.java:67) at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:41) at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35) at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145) I am confused on what exactly is going on and have updated all my dependencies to match the current version required by aShot/ Thank you for your time on this.

valfirst commented 1 year ago

@CalumR23 do you have full exception stacktrace? or any other details? it's hard to imagine what's happened

CalumR23 commented 1 year ago

@valfirst the only code that works is: Screenshot myScreenshot = new AShot().takeScreenshot(webDriver); Whenever I add a ShootingStrategy to it or webElement, I get the above error. I am running this thru inellij and even after running with --stacktrace its almost the same as above: java.lang.Exception: org.apache.commons.io.IOUtils.toString(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Ljava/lang/String; at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:27) at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getFullHeight(ViewportPastingDecorator.java:67) at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:41) at ru.yandex.qatools.ashot.shooting.ViewportPastingDecorator.getScreenshot(ViewportPastingDecorator.java:35) at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:145) at com.liferay.poshi.runner.selenium.BaseWebDriverImpl.aShotAssertElementImage(BaseWebDriverImpl.java:2115)

BaseWebDriverImpl is the file I am creating the new aShot as shown above.

CalumR23 commented 1 year ago

Heres when using a webElement: WebElement webElement = getWebElement(locator); Screenshot myScreenshot = new AShot().takeScreenshot(webDriver, webElement); The error is : java.lang.Exception: org.apache.commons.io.IOUtils.toString(Ljava/io/InputStream;Ljava/nio/charset/Charset;)Ljava/lang/String; /opt/dev/projects/github/poshi-dev-tools/src/test/resources/poshiFiles/PoshiScriptTest.testcase[MyTest]:6 at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:27) at ru.yandex.qatools.ashot.util.JsCoords.findCoordsWithJquery(JsCoords.java:24) at ru.yandex.qatools.ashot.coordinates.JqueryCoordsProvider.ofElement(JqueryCoordsProvider.java:14) at ru.yandex.qatools.ashot.coordinates.CoordsProvider.ofElements(CoordsProvider.java:21) at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:116) at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:134)