本文整理汇总了TypeScript中protractor.browser.executeScript方法的典型用法代码示例。如果您正苦于以下问题:TypeScript browser.executeScript方法的具体用法?TypeScript browser.executeScript怎么用?TypeScript browser.executeScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类protractor.browser
的用法示例。
在下文中一共展示了browser.executeScript方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(){
navigateTo('/');
browser.executeScript('window.localStorage.clear();');
browser.executeScript('window.stop();');
browser.sleep(1000);
browser.waitForAngularEnabled(false);
}
示例2: clearLocalStorage
export async function clearLocalStorage() {
await navigateToRoute('/');
await browser.executeScript(() => {
const injector = angular.element(document.body).injector();
const LocalStorageService: any = injector.get('LocalStorageService');
return LocalStorageService.clearAll();
});
const visited = await browser.executeScript(() => {
const injector = angular.element(document.body).injector();
const LocalStorageService: any = injector.get('LocalStorageService');
return LocalStorageService.get('scenariooPreviouslyVisited');
});
await expect(visited).toBe(null);
}
示例3: element
.then((options) => {
// Figure out which one we want
let index = npmTiles.findIndex((tile) => tile === importOption);
let optionElement = options[index].getWebElement();
// Scroll into view
browser.executeScript('arguments[0].scrollIntoView();', optionElement);
// Click
optionElement.click();
// Confirm
let confirmElement = element(by.id('import_confirm'));
browser.executeScript('arguments[0].scrollIntoView();', confirmElement);
OperationsHelper.click(confirmElement);
});
示例4:
return location.getWebElement().then((element) => {
// bind a new input to the drop area
browser.executeScript(BIND_INPUT, element).then((input) => {
// upload the file to the new input
(input as any).sendKeys(filePath);
});
});
示例5: it
it('trying to have two tabs with the same title should fail', async () => {
let newTabBtn = element(by.id('new-tab-button'));
// Set up two tabs
newTabBtn.click();
let tabs = element.all(by.css('#tab-bar .nav-item'));
expect(await tabs.count()).toBe(2);
expect(await tabs.get(0).getText()).toBe('Tab # 1');
expect(await tabs.get(1).getText()).toBe('Tab # 2');
// Rename second oab
browser.executeScript('arguments[0].click()',
element(by.css('#tab-bar .nav-item:last-child .edit-tab')));
let input = element(by.css('#tab-bar .nav-item:last-child .tab-title-editor'));
browser.wait(() => { return input.isDisplayed(); }, 1000);
// Error status
input.sendKeys('Tab # 1');
input.sendKeys(protractor.Key.ENTER);
expect(await input.getAttribute('class')).toMatch('has-error');
expect(await input.isDisplayed()).toBe(true);
// Esc doesn't let you leave editing
input.sendKeys(protractor.Key.ESCAPE);
expect(await input.isDisplayed()).toBe(true);
// Sending a new key remove the error status
input.sendKeys('0');
input.sendKeys(protractor.Key.ENTER);
expect(await input.getAttribute('class')).not.toMatch('has-error');
let closeTabBtn = element(by.css('#tab-bar .nav-item.active .close-tab'));
closeTabBtn.click();
});
示例6: retrieveEditorCodeMirrorText
static retrieveEditorCodeMirrorText() {
return browser.executeScript(`
var editor = document.getElementsByClassName('CodeMirror')[0].CodeMirror;
editor.focus();
return editor.getValue();
`)
}
示例7: enterBigConfigurationText
enterBigConfigurationText(text) {
let textField = element(by.css('#adf-code-configuration-editor div.overflow-guard > textarea'));
Util.waitUntilElementIsVisible(textField);
browser.executeScript('this.monaco.editor.getModels()[0].setValue(`' + text + '`)');
return this;
}
示例8:
.then(() => {
return browser.executeScript(`
var editor = document.getElementsByClassName('CodeMirror')[0].CodeMirror;
editor.focus();
return editor.setValue('');
`)
})