Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
showFilter(name) {
const addFilterButton = driver.findElement(
this.elements.addFilterButton
);
addFilterButton.click();
driver.sleep(500); // wait until the dropdown animation ends
driver.wait(until.elementLocated(this.elements.filterMenuItem(name)));
driver.findElement(this.elements.filterMenuItem(name)).click();
return this.waitUntilDataLoaded();
},
// Check that there is a login button
driver.findElement( By.css('a[href="/login/"]') )
.then(function(el){
return el.getText();
})
.then(function(text){
expect(text).to.be.equal('Login');
});
// Click on Login button
driver.findElement( By.css('a[href="/login/"]') )
.then(function(el){
return el.click();
});
driver.wait(until.elementLocated(By.css('h1')), 1000);
// Check that it is actually login page
driver.findElement( By.css('h1') )
.then(function(el){
return el.getText();
})
.then(function(text){
expect(text).to.be.equal('Login');
});
// Fill login form
Promise.all([
_.map(
[
{
selector : 'input[name="username"]',
export const load = async () => {
await driver.get(`${__baseUrl__}/`);
await driver.wait(until.elementLocated(root), defaultTimeout);
};
async capturePageAsPng_({driver, userAgent, url, delayMs = 0}) {
this.logStatus_(CliStatuses.GET, `${url} > ${userAgent.alias}...`);
const isOnline = await this.cli_.isOnline();
const fontTimeoutMs = isOnline ? SELENIUM_FONT_LOAD_WAIT_MS : 500;
await driver.get(url);
await driver.wait(until.elementLocated(By.css('[data-fonts-loaded]')), fontTimeoutMs).catch(() => 0);
if (delayMs > 0) {
await driver.sleep(delayMs);
}
const uncroppedImageBuffer = Buffer.from(await driver.takeScreenshot(), 'base64');
const croppedImageBuffer = await this.imageCropper_.autoCropImage(uncroppedImageBuffer);
const uncroppedJimpImage = await Jimp.read(uncroppedImageBuffer);
const croppedJimpImage = await Jimp.read(croppedImageBuffer);
const {width: uncroppedWidth, height: uncroppedHeight} = uncroppedJimpImage.bitmap;
const {width: croppedWidth, height: croppedHeight} = croppedJimpImage.bitmap;
const message = `${url} > ${userAgent.alias} screenshot from ` +
`${uncroppedWidth}x${uncroppedHeight} to ${croppedWidth}x${croppedHeight}`;
async waitForCustomizer() {
const self = this;
self.driver
.wait( until.elementLocated( this.metaiFrameElementSelector ), this.explicitWaitMS * 2 )
.then(
function() {},
function( error ) {
const message = `Found issue on customizer page: '${ error }' - Clicking try again button now.`;
slackNotifier.warn( message );
self.driver
.wait( function() {
return driverHelper.isElementPresent( self.driver, self.reloadCustomizerSelector );
}, self.explicitWaitMS )
.then(
function() {
driverHelper.clickWhenClickable(
self.driver,
self.reloadCustomizerSelector,
self.explicitWaitMS
);
export default function webChatLoaded() {
return until.elementLocated(By.css('[role="log"]'));
}
async waitToReport() {
try {
const toasts = await this.driver.wait(until.elementLocated(By.css('div.euiGlobalToastList')), 10000);
await this.driver.wait(until.elementTextContains(toasts, 'Reporting. Success.'), 60000);
return true;
} catch (error) {
return false;
}
}
async addSearchEngine(): Promise {
const rows = await this.webdriver.findElements(By.css(`.form-search-form-row > .column-name`));
const button = await this.webdriver.findElement(By.css('.form-search-form > .ui-add-button'))
await button.click();
await this.webdriver.wait(until.elementLocated(By.css(`.form-search-form-row:nth-child(${rows.length + 1})`)));
}
waitUntilVisible() {
return driver.wait(until.elementLocated(this.elements.title));
},