Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ashot is failing to take coordinate/Screenshot in chrome 79.0.3945.130 and selenium 3.141.59 #188

Closed
shaileshoptimizeq opened this issue Feb 11, 2020 · 5 comments

Comments

@shaileshoptimizeq
Copy link

I have encountered a weird problem while working with AShot. Ashot works fine for whole screenShots but while selective screenShot is BAD. It throws error in CoordsProvider Class while getting co-ordinates of element.

public abstract class CoordsProvider implements Serializable {

public abstract Coords ofElement(WebDriver driver, WebElement element);

public Set ofElements(WebDriver driver, Iterable elements) {
Set elementsCoords = new HashSet<>();
for (WebElement element : elements) {
Coords elementCoords = ofElement(driver, element); //fails here
if (!elementCoords.isEmpty()) {
elementsCoords.add(elementCoords);
}
}
return Collections.unmodifiableSet(elementsCoords);
}

@SuppressWarnings("UnusedDeclaration")
public Set ofElements(WebDriver driver, WebElement... elements) {
return ofElements(driver, Arrays.asList(elements));
}

@SuppressWarnings("UnusedDeclaration")
public Set locatedBy(WebDriver driver, By locator) {
return ofElements(driver, driver.findElements(locator));
}
}

Stack Trace
org.openqa.selenium.JavascriptException: javascript error: $ is not defined
(Session info: chrome=79.0.3945.130)
Build info: version: '3.14.0', revision: 'aacccce0', time: '2018-08-02T20:19:58.91Z'
System info: host: 'OPTIMIZEQ-LTP03', ip: '192.168.99.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.2'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 79.0.3945.130, chrome: {chromedriverVersion: 78.0.3904.105 (60e2d8774a81..., userDataDir: C:\Users\SHAILE~1.SIN\AppDa...}, goog:chromeOptions: {debuggerAddress: localhost:61006}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, proxy: Proxy(manual, http=localhos..., setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webdriver.remote.sessionid: f5a47b27537f019dacb73462732...}
Session ID: f5a47b27537f019dacb734627324a790
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187) ~[selenium-remote-driver-3.14.0.jar:na]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122) ~[selenium-remote-driver-3.14.0.jar:na]
at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49) ~[selenium-remote-driver-3.14.0.jar:na]
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158) ~[selenium-remote-driver-3.14.0.jar:na]
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548) ~[selenium-remote-driver-3.14.0.jar:na]
at org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:485) ~[selenium-remote-driver-3.14.0.jar:na]
at ru.yandex.qatools.ashot.util.JsCoords.findCoordsWithJquery(JsCoords.java:30) ~[ashot-1.5.2.jar:na]
at ru.yandex.qatools.ashot.coordinates.JqueryCoordsProvider.ofElement(JqueryCoordsProvider.java:13) ~[ashot-1.5.2.jar:na]
at ru.yandex.qatools.ashot.coordinates.CoordsProvider.ofElements(CoordsProvider.java:21) ~[ashot-1.5.2.jar:na]
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:115) ~[ashot-1.5.2.jar:na]
at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:132) ~[ashot-1.5.2.jar:na]
at com.optq.main.util.SeleniumDriverUtility.captureAShotElement(SeleniumDriverUtility.java:563) ~[classes/:na]

@valfirst
Copy link
Collaborator

@shaileshoptimizeq use WebDriverCoordsProvider instead of JqueryCoordsProvider. Also you use a quite old version of the library, the default behavior already has been changed: 3113942

@shaileshoptimizeq
Copy link
Author

public class AShot implements Serializable {
    **private CoordsProvider coordsProvider = new JqueryCoordsProvider()**;
    private ImageCropper cropper = new DefaultCropper();
    private Set<By> ignoredLocators = new HashSet<>();
    private Set<Coords> ignoredAreas = new HashSet<>();
    private ShootingStrategy shootingStrategy = new SimpleShootingStrategy();

    public AShot coordsProvider(final CoordsProvider coordsProvider) {
        this.coordsProvider = coordsProvider;
        return this;
    }

    @SuppressWarnings("UnusedDeclaration")
    public AShot imageCropper(ImageCropper cropper) {
        this.cropper = cropper;
        return this;
    }
.
.
.
}

I am using V 1.54 I guess which is latest one in maven repo.
ScreenShot here https://i.stack.imgur.com/dQeCK.png
My question https://stackoverflow.com/questions/60167466/org-openqa-selenium-javascriptexception-javascript-error-is-not-defined-erro
need your help on this.

@valfirst
Copy link
Collaborator

valfirst commented Feb 12, 2020

@shaileshoptimizeq according to your stack trace:

at ru.yandex.qatools.ashot.AShot.takeScreenshot(AShot.java:132) ~[ashot-1.5.2.jar:na]

you use 1.5.2, not 1.5.4


Just to clarify: the default behavior is changed, but not released, so you can use snapshots or follow my first recommendation:

use WebDriverCoordsProvider instead of JqueryCoordsProvider.

@shaileshoptimizeq
Copy link
Author

yes i, have changed to 1.5.4 then also but is no good. i have given url just copy paste and verify it.and how do i change Internal implementation of AShot.class file.

@valfirst
Copy link
Collaborator

@shaileshoptimizeq obviously you need to use setter: AShot.java#L33

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants