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

Getting "unknown error: $ is not defined" Error.. #93

Closed
sgoltekar opened this issue Jan 22, 2017 · 6 comments
Closed

Getting "unknown error: $ is not defined" Error.. #93

sgoltekar opened this issue Jan 22, 2017 · 6 comments

Comments

@sgoltekar
Copy link

Hello,

I am getting erorr on "Screenshot screenshot = new AShot().takeScreenshot(driver, driver.findElement(By.xpath("//*[@id='rc-imageselect-target']")));"

Any advice?

`<dependency>
	<groupId>ru.yandex.qatools.ashot</groupId>
	<artifactId>ashot</artifactId>
	<version>1.5.2</version>
</dependency>`

Code:

private void downloadImg(String imageName, String userCode) { try { Screenshot screenshot = new AShot().takeScreenshot(driver, driver.findElement(By.xpath("//*[@id='rc-imageselect-target']"))); ImageIO.write(screenshot.getImage(), "PNG", new File(imageName)); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } }

org.openqa.selenium.WebDriverException: unknown error: $ is not defined
(Session info: chrome=55.0.2883.95)
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 15 milliseconds
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:49:13 -0700'
System info: host: 'ITs-MacBook-Pro-7.local', ip: '10.0.0.249', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.2', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, networkConnectionEnabled=false, chrome={chromedriverVersion=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9), userDataDir=/var/folders/41/pzbtm1m57h9fpx78wl8hvp6mh6vxg_/T/.org.chromium.Chromium.nEk9HB}, takesHeapSnapshot=true, pageLoadStrategy=normal, databaseEnabled=false, handlesAlerts=true, hasTouchScreen=false, version=55.0.2883.95, platform=MAC, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webStorageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true, unexpectedAlertBehaviour=}]
Session ID: 8126033dc0318682269890c03bd41228

@OlehPitsyc
Copy link

Hello!
I have tried to use addIgnoredElement method, and it returned error (screenshot: http://prntscr.com/e9a37q)
I have read some articles about it in your github issues, but there were nothing, about this error in my case with addIgnoredElement. In all other cases it works perfect.
Please help!

@pazone
Copy link
Owner

pazone commented Feb 16, 2017

use aShot.coordsProvider(new WebDriverCoordsProvider())

@pazone pazone closed this as completed Feb 16, 2017
@ksiv
Copy link

ksiv commented May 17, 2018

any idea why have you closed the issue?
it still fires:
org.openqa.selenium.WebDriverException: unknown error: $ is not defined
Expected:
ru.yandex.qatools.ashot.coordinates..CoordsProvider.Exception: "use aShot.coordsProvider(new WebDriverCoordsProvider())"

@sjethvani
Copy link

sjethvani commented May 30, 2018

I was also getting same issue . At below line I am getting exception
Screenshot screenshot = new AShot().takeScreenshot(driver,driver.findElement(By.xpath(webElementXpath)));

Exception
`java.lang.RuntimeException: org.openqa.selenium.WebDriverException: unknown error: $ is not defined
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'AMD0-SJETHVAN-02.local', ip: 'fe80:0:0:0:144b:ae4a:2606:c0d2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.36.540469 (1881fd7f864150..., userDataDir: /var/folders/ym/dtyc5vz9785...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true, webdriver.remote.sessionid: 3475027cb4404809a4263a44714...}
Session ID: 3475027cb4404809a4263a447145112d
at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:32)
at ru.yandex.qatools.ashot.util.JsCoords.findCoordsWithJquery(JsCoords.java:24)

Update
I resolved it using
Screenshot screenshot = new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(driver,driver.findElement(By.xpath(webElementXpath)));

@ipsitah
Copy link

ipsitah commented Dec 11, 2018

Thanks sjethvani & ksiv It worked for me now.

@AkshathaSR
Copy link

I was also getting same issue . At below line I am getting exception
Screenshot screenshot = new AShot().takeScreenshot(driver,driver.findElement(By.xpath(webElementXpath)));

Exception
`java.lang.RuntimeException: org.openqa.selenium.WebDriverException: unknown error: $ is not defined
(Session info: chrome=66.0.3359.181)
(Driver info: chromedriver=2.36.540469 (1881fd7f8641508feb5166b7cae561d87723cfa8),platform=Mac OS X 10.12.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T18:33:54.468Z'
System info: host: 'AMD0-SJETHVAN-02.local', ip: 'fe80:0:0:0:144b:ae4a:2606:c0d2%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_121'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.36.540469 (1881fd7f864150..., userDataDir: /var/folders/ym/dtyc5vz9785...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 66.0.3359.181, webStorageEnabled: true, webdriver.remote.sessionid: 3475027cb4404809a4263a44714...}
Session ID: 3475027cb4404809a4263a447145112d
at ru.yandex.qatools.ashot.util.InnerScript.execute(InnerScript.java:32)
at ru.yandex.qatools.ashot.util.JsCoords.findCoordsWithJquery(JsCoords.java:24)

Update
I resolved it using
Screenshot screenshot = new AShot().coordsProvider(new WebDriverCoordsProvider()).takeScreenshot(driver,driver.findElement(By.xpath(webElementXpath)));

Your answer really helped me. Thak you..

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

7 participants