How to use the protractor.browser.executeScript function in protractor

To help you get started, we’ve selected a few protractor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FINRAOS / herd-ui / e2e / app / base / base.po.ts View on Github external
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');
    }
  }
github Alfresco / alfresco-ng2-components / lib / testing / src / lib / core / utils / browser-actions.ts View on Github external
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;
          }
        }
    }
github blockstack / blockstack-browser / test-e2e / features / step_definitions / sign.steps.ts View on Github external
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 () => {
github Alfresco / alfresco-ng2-components / e2e / content-services / version / version-actions.e2e.ts View on Github external
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);
    });
github Alfresco / alfresco-ng2-components / e2e / pages / adf / dialog / uploadToggles.ts View on Github external
async enableExtensionFilter(): Promise {
        await browser.executeScript('arguments[0].scrollIntoView()', this.extensionFilterToggle);
        await this.formControllersPage.enableToggle(this.extensionFilterToggle);
    }
github skycoin / skycoin-web / e2e / onboarding-create.po.ts View on Github external
private clickOutsideModal() {
    return browser.executeScript('arguments[0].click()', element(by.css('.cdk-overlay-backdrop')));
  }
github Gapminder / gapminder-offline / e2e / helpers / helper.ts View on Github external
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);`)
}
github bleenco / abstruse / e2e / 120_team.e2e.ts View on Github external
      .then(ele => browser.executeScript('arguments[0].scrollIntoView();', ele.getWebElement()))
      .then(() => element(by.css('[name="btn-saveNewUser"]')).click())
github Alfresco / alfresco-ng2-components / e2e / pages / adf / notificationPage.ts View on Github external
async clickActionButton(): Promise {
        await browser.executeScript(`document.querySelector("simple-snack-bar > div > button").click();`);
    }