Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// ...if that element's text matches ...
if (text === datafield_label) {
return elem.isDisplayed().then(function (is_displayed) {
// ...and that element is currently displayed...
if (is_displayed === true) {
// ...then store the content of the "for" attribute (which should be an id in this case)
return elem.getAttribute('for').then(function (id) {
return id;
});
}
});
}
});
});
webdriver.promise.all(datafields).then(function (elements) {
// The datafields variable currently is an array of all html elements matching the
// "label.ODRFieldLabel" css selector...however, every entry that didn't match
// and was not visible is currently undefined, and should be
// filtered out...
var matching_datafields = elements.filter(function (elem) {
if (typeof elem !== "undefined")
return true;
});
if (matching_datafields.length === 0)
throw('No visible datafield has the label "' + datafield_label + '"');
// console.log( matching_datafields );
// Now, for each id stored in "matching_datafields"...
matching_datafields.forEach(function (id) {
beforeEach(function (done) {
result = undefined;
sinon.stub(subject.driver, 'executeScript').onFirstCall().returns(webdriver.promise.fulfilled({coverage: 'object'}));
subject.driver.executeScript.onSecondCall().returns(webdriver.promise.rejected(new Error('error')));
var promised = expectedWrappedObject.expectedWrappedFunction('first arg', 'second arg');
promised.then(function (output) {
result = output;
done();
}); // a lack of reject path here implies (unfortunately) that this should NOT reject
});
it('calls the wrapped function with those arguments', function (done) {
run() {
let testPassed;
let plugins = this.plugins_ = new plugins_1.Plugins(this.config_);
let pluginPostTestPromises;
let browser_;
let results;
if (this.config_.framework !== 'explorer' && !this.config_.specs.length) {
throw new Error('Spec patterns did not match any files.');
}
if (this.config_.SELENIUM_PROMISE_MANAGER != null) {
selenium_webdriver_1.promise.USE_PROMISE_MANAGER = this.config_.SELENIUM_PROMISE_MANAGER;
}
if (this.config_.webDriverLogDir || this.config_.highlightDelay) {
this.config_.useBlockingProxy = true;
}
// 0) Wait for debugger
return q(this.ready_)
.then(() => {
// 1) Setup environment
// noinspection JSValidateTypes
return this.driverprovider_.setupEnv();
})
.then(() => {
// 2) Create a browser and setup globals
browser_ = this.createBrowser(plugins);
this.setupGlobals_(browser_);
return browser_.ready.then(browser_.getSession)
validatePortAvailability_(port) {
if (this.debuggerValidated_) {
return selenium_webdriver_1.promise.when(false);
}
let doneDeferred = selenium_webdriver_1.promise.defer();
// Resolve doneDeferred if port is available.
let tester = net.connect({ port: port }, () => {
doneDeferred.reject('Port ' + port + ' is already in use. Please specify ' +
'another port to debug.');
});
tester.once('error', (err) => {
if (err.code === 'ECONNREFUSED') {
tester
.once('close', () => {
doneDeferred.fulfill(true);
})
.end();
}
else {
UI5FormAuthenticator.prototype.get = function(url){
var that = this;
if (!this.user || !this.pass) {
return webdriver.promise.rejected(
new Error('UI5 Form auth requested but user or pass is not specified'));
}
// open the page
browser.driver.get(url);
// synchronize with UI5 on credentials page
browser.loadUI5Dependencies();
// collect login actions separately
this.statisticsCollector.authStarted();
// enter user and pass in the respective fields
element(by.css(this.userFieldSelector)).sendKeys(this.user);
element(by.css(this.passFieldSelector)).sendKeys(this.pass);
element(by.css(this.logonButtonSelector)).click().then(function () {
// wait for all login actions to complete
exports.promiseClick = function(driver, selector, timeout) {
var def = webdriver.promise.defer();
timeout = timeout || WAIT_TIMEOUT;
driver.wait(function() {
console.log("Waiting on click...", selector);
return (driver.isElementPresent(selector));
}, 10000).then(function() {
console.log("Waiting for click done");
driver.findElement(selector).click().then(function() {
def.fulfill(null);
});
});
return def.promise;
}
function setupExceptions(test, done) {
console.log("setting up exceptions");
webdriver.promise.controlFlow().on('uncaughtException', function(e) {
console.error('Unhandled error: ' + e);
test.fail(new Error("Unhandled exception: " + e));
done();
});
}
openTab( requestedTab ) {
var self = this;
var d = webdriver.promise.defer();
this.getCurrentTab().then( function( currTab ) {
if ( currTab !== requestedTab ) {
const selector = By.xpath( `//XCUIElementTypeButton[@name="${requestedTab}"]` );
driverHelper.clickWhenClickableMobile( self.driver, selector ).then( function() {
d.fulfill();
} );
}
} );
return d.promise;
}
}
function buildDriver(caps, resolve, reject) {
const flow = new webdriver.promise.ControlFlow()
.on('uncaughtException', reject);
const builder = new webdriver.Builder();
if (hub.serverUrl) {
builder.usingServer(hub.serverUrl);
}
return builder
.withCapabilities(caps)
.setControlFlow(flow)
.build();
}
quitDriver() {
return selenium_webdriver_1.promise.when(undefined);
}
}