admc / wd

A node.js client for webdriver/selenium 2.
Other
1.53k stars 402 forks source link

Add getElementScreen #536

Closed zcmgyu closed 4 years ago

zcmgyu commented 6 years ago

In Java client I could get screenshot of element, but WD wasn't implemented this method, though getElementScreen API's also prepared already.

'/wd/hub/session/:sessionId/element/:elementId/screenshot': { GET: {command: 'getElementScreenshot'} }

Usage:

await element.getElementScreen();

or

await driver.getElementScreen(element);

jlipps commented 6 years ago

@zcmgyu thank you for this. I'd prefer to review this without all the extraneous styling changes, however. Is that something you did manually or did it get reformatted by your IDE?

admc commented 5 years ago

Greetings, when I run our unit tests "gulp test-midway-chrome", with selenium jar 3.9.1 I get the following error with your branch:

1) element (local, chrome) element.sendKeys: AssertionError: expected '/Users/adam/projects/wd/test/mocha.opts' to not include '/Users/adam/projects/wd/test/mocha.opts' at test/midway/element-specs.js:225:28 at _fulfilled (node_modules/q/q.js:834:54) at node_modules/q/q.js:863:30 at Promise.promise.promiseDispatch (node_modules/q/q.js:796:13) at node_modules/q/q.js:604:44 at runSingle (node_modules/q/q.js:137:13) at flush (node_modules/q/q.js:125:13) at process._tickCallback (internal/process/next_tick.js:61:11)

Thoughts?