Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async clearContentsShim(elm: ElementFinder, replacement?: string): Promise {
if ((await elm.getText()).trim() !== '') {
// select the content and then send the delete key to delete the contents
const script =
`var range = document.createRange();
range.selectNodeContents(arguments[0]);
range.deleteContents();
arguments[0].innerHTML = arguments[1];`;
return browser.executeScript(script, elm.getWebElement(), replacement || `''`);
} else {
return Promise.resolve('no contents in the element');
}
}
static async click(elementFinder: ElementFinder): Promise {
try {
await BrowserVisibility.waitUntilElementIsVisible(elementFinder);
await BrowserVisibility.waitUntilElementIsClickable(elementFinder);
await elementFinder.click();
} catch (clickErr) {
try {
await browser.executeScript(`arguments[0].scrollIntoView();`, elementFinder);
await browser.executeScript(`arguments[0].click();`, elementFinder);
} catch (jsErr) {
Logger.error(`click error element ${elementFinder.locator()}`);
throw jsErr;
}
}
}
this.Then(/^fast account recovery via localStorage update$/, async () => {
await browser.executeScript(`
window.localStorage.setItem("BLOCKSTACK_STATE_VERSION", "ignore");
var authedReduxObj = JSON.parse(arguments[0]);
var localReduxObj = JSON.parse(window.localStorage.getItem("redux"));
var mergedReduxState = Object.assign({}, localReduxObj, authedReduxObj);
window.localStorage.setItem("redux", JSON.stringify(mergedReduxState));
`, SampleAccount.LOCAL_STORAGE_DATA);
});
this.Then(/^load page$/, async () => {
it('[C307033] Should be possible to cancel the upload of a new version', async () => {
await browser.refresh();
await contentServicesPage.versionManagerContent(txtFileModel.name);
await browser.executeScript(' setTimeout(() => {document.querySelector("div[data-automation-id=\'cancel-upload-progress\']").click();}, 1000)');
await BrowserActions.click(versionManagePage.showNewVersionButton);
await versionManagePage.uploadNewVersionFile(bigFileToCancel.location);
await versionManagePage.closeVersionDialog();
await expect(await uploadDialog.getTitleText()).toEqual('Upload canceled');
await browser.refresh();
await navigationBarPage.clickContentServicesButton();
await contentServicesPage.waitForTableBody();
await contentServicesPage.checkContentIsDisplayed(txtFileModel.name);
});
async enableExtensionFilter(): Promise {
await browser.executeScript('arguments[0].scrollIntoView()', this.extensionFilterToggle);
await this.formControllersPage.enableToggle(this.extensionFilterToggle);
}
private clickOutsideModal() {
return browser.executeScript('arguments[0].click()', element(by.css('.cdk-overlay-backdrop')));
}
export function disableAnimations() {
return browser.executeScript(`var style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = '* {' +
'-webkit-transition: none !important;' +
'-moz-transition: none !important' +
'-o-transition: none !important' +
'-ms-transition: none !important' +
'transition: none !important' +
'}';
document.getElementsByTagName('head')[0].appendChild(style);`)
}
.then(ele => browser.executeScript('arguments[0].scrollIntoView();', ele.getWebElement()))
.then(() => element(by.css('[name="btn-saveNewUser"]')).click())
async clickActionButton(): Promise {
await browser.executeScript(`document.querySelector("simple-snack-bar > div > button").click();`);
}