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

Fix terminal command now return actual result from Selenium #4155

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
20 changes: 18 additions & 2 deletions lib/api/web-element/scoped-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {ShadowRoot} = require('selenium-webdriver/lib/webdriver');
const {Logger, isFunction, createPromise} = require('../../utils/');
const {WEB_ELEMENT_ID} = require('../../transport/selenium-webdriver/session.js');
const {ScopedElementLocator} = require('./element-locator.js');
const {error} = require('console');

class ScopedWebElement {

Expand Down Expand Up @@ -265,7 +266,14 @@ class ScopedWebElement {
this.webElement = promise;
} else {
this.webElement = new WebElementPromise(this.driver, this.then(async (element) => {
await promise;
const result = await promise;
if (result && result.status === -1) {
return {
'error': result.error.name,
'message': result.error.message,
'stack': result.error.stack
};
}

return element;
}));
Expand All @@ -290,7 +298,15 @@ class ScopedWebElement {
return commandName(webElement, ...args);
}

return actions[commandName](webElement, ...args);

return actions[commandName](webElement, ...args).then((result) => {
if (result && result.status === -1) {
node.deferred.resolve(result);
} else {
// eslint-disable-next-line no-prototype-builtins
node.deferred.resolve(result.hasOwnProperty('value') ? result.value : result);
}
});
};

const node = this.queueAction({name: commandName, createAction});
Expand Down
Loading