本文整理匯總了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('');
`)
})