Skip to content

Element Selector fix for Webdriver Version 5.0 #5

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

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,25 @@ class ResembleHelper extends Helper {
async _getBoundingBox(selector){
const browser = this._getBrowser();

var ele = await browser.element(selector)
.then((res) => {
return res;
})
.catch((err) => {
// Catch the error because webdriver.io throws if the element could not be found
// Source: https://github.com/webdriverio/webdriverio/blob/master/lib/protocol/element.js
return null;
});
var location = await browser.getLocation(selector);
var size = await browser.getElementSize(selector);
if (this.helpers['WebDriver']) {
const ele = await browser.$(selector);
var location = await ele.getLocation();
var size = await ele.getSize();
}
else {
var ele = await browser.element(selector)
.then((res) => {
return res;
})
.catch((err) => {
// Catch the error because webdriver.io throws if the element could not be found
// Source: https://github.com/webdriverio/webdriverio/blob/master/lib/protocol/element.js
return null;
});
var location = await browser.getLocation(selector);
var size = await browser.getElementSize(selector);
}

var bottom = size.height + location.y;
var right = size.width + location.x;
var boundingBox = {
Expand Down