本文整理汇总了TypeScript中protractor/globals.by类的典型用法代码示例。如果您正苦于以下问题:TypeScript by类的具体用法?TypeScript by怎么用?TypeScript by使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了by类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should allow editing courses', () => {
// Check browser url (dashboard)
expect(browser.driver.getCurrentUrl()).toMatch('/courses');
// Get and click the button to edit the last one of the courses
var lastEditCoursesIcon = element.all(by.className('course-put-icon')).last();
page.waitUntilElementNotVisible('#course-modal');
lastEditCoursesIcon.click();
page.waitUntilElementPresent('#put-delete-course-modal');
// Get field inputs
var courseNameField = browser.driver.findElement(by.id('inputPutCourseName'));
// Fill input field
courseNameField.clear();
courseNameField.sendKeys('[EDITED]');
// Ensure field contains what has been entered
expect(courseNameField.getAttribute('value')).toEqual('[EDITED]');
browser.driver.findElement(by.id('submit-put-course-btn')).then(function(submitEditCourseBtn) {
// Click submit form
submitEditCourseBtn.click().then(function() {
browser.waitForAngular();
//The last course should have changed its name
var editedCourse = element.all(by.className('course-title')).last();
expect(editedCourse.getText()).toEqual('[EDITED]');
});
});
});
示例2: expect
welcomeBtn.click().then(function() {
// Find form elements
var userNameField = browser.driver.findElement(by.id('email'));
var userPassField = browser.driver.findElement(by.id('password'));
// Fill input fields
userNameField.sendKeys('wrongemail@gmail.com');
userPassField.sendKeys('pass');
// Ensure fields contain what has been entered
expect(userNameField.getAttribute('value')).toEqual('wrongemail@gmail.com');
expect(userPassField.getAttribute('value')).toEqual('pass');
browser.driver.findElement(by.id('log-in-btn')).then(function(loginBtn) {
// Click to log in - waiting for Angular as it is manually bootstrapped.
loginBtn.click().then(function() {
browser.waitForAngular();
// Error message appears warning about an invalid field
expect(browser.driver.findElement(by.tagName('app-error-message')).getText()).toContain('Invalid field');
//Route mustn't change
expect(browser.driver.getCurrentUrl()).toMatch('/');
// Clear field inputs
userNameField.clear();
userPassField.clear();
});
});
});
示例3: getIconButton
getIconButton(name: string, className: string) {
return element.all(by.css('table>tbody>tr')).filter(row => {
return row.all(by.tagName('td')).get(0).getText().then(pName => {
return pName === name;
})
}).get(0).element(by.css(className));
}
示例4: getFormData
getFormData() {
let mainPanel = element.all(by.css('.metron-slider-pane-edit')).last();
return protractor.promise.all([
mainPanel.element(by.css('.form-title')).getText(),
mainPanel.element(by.css('input[name="sensorTopic"]')).getAttribute('value'),
mainPanel.element(by.css('select[formcontrolname="parserClassName"]')).getAttribute('value'),
mainPanel.element(by.css('input[formcontrolname="grokStatement"]')).getAttribute('value'),
mainPanel.all(by.css('div[name="fieldSchema"] table tr')).getText(),
mainPanel.all(by.css('div[name="threatTriage"] table tr')).getText(),
mainPanel.element(by.css('input[formcontrolname="index"]')).getAttribute('value'),
mainPanel.element(by.css('metron-config-number-spinner[name="batchSize"] input')).getAttribute('value'),
mainPanel.all(by.css('metron-config-advanced-form input')).getAttribute('value')
]).then(args => {
return {
title: args[0],
parserName: args[1],
parserType: args[2],
grokStatement: args[3],
fieldSchemaSummary: args[4],
threatTriageSummary: args[5],
indexName: args[6],
batchSize: args[7],
advancedConfig: args[8]
}
});
}
示例5: getActions
getActions(name: string) {
return element.all(by.css('table>tbody>tr')).filter(row => {
return row.all(by.tagName('td')).get(0).getText().then(pName => {
return pName === name;
})
}).get(0).all(by.tagName('i')).map(icon => {
return icon.getAttribute('class').then(classNames => {
let className = classNames.replace('fa ', '').replace('fa-lg', '').replace('fa-spin fa-fw', '').trim();
return {classNames: className, displayed: icon.isDisplayed()};
});
});
}
示例6: getDropdownActionState
getDropdownActionState() {
return protractor.promise.all([
element.all(by.css('.dropdown.open .dropdown-menu span:not(.disabled)')).count(),
element.all(by.css('.dropdown.open .dropdown-menu span.disabled')).count(),
element.all(by.css('.dropdown-menu')).isDisplayed()
]).then(args => {
return {
enabled: args[0],
disabled: args[1],
displayed: args[2][0],
}
});
}
示例7: element
element(by.css('.card-panel.warning')).isPresent().then(function(pres) {
if (pres) {
element(by.css('#edit-forum-icon')).click().then(function() {
page.waitForAnimation();
// Get and click the checkbox to allow the forum's activation
browser.driver.findElement(by.css('label[for=delete-checkbox]')).then(function(activationAllowed) {
activationAllowed.click();
// Get and click the button to activate the forum
browser.driver.findElement(by.css('#put-modal-btn')).then(function(activateButton) {
activateButton.click().then(function() {
browser.waitForAngular();
page.waitForAnimation();
page.waitUntilElementPresent('#add-entry-icon');
});
});
});
});
}
browser.driver.findElement(by.css('#add-entry-icon')).then(function(btn) {
btn.click().then(function() {
page.waitUntilElementPresent('#course-details-modal');
// Find form elements
var entryTitleField = browser.driver.findElement(by.css('input#inputTitle'));
var entryCommentField = browser.driver.findElement(by.css('textarea#inputComment'));
// Fill input fields
entryTitleField.sendKeys('New testing entry title');
entryCommentField.sendKeys('New testing entry comment');
// Ensure fields contain what has been entered
expect(entryTitleField.getAttribute('value')).toEqual('New testing entry title');
expect(entryCommentField.getAttribute('value')).toEqual('New testing entry comment');
// Send new entry
browser.driver.findElement(by.css('#post-modal-btn')).then(function(sendButton) {
sendButton.click().then(function() {
browser.waitForAngular();
page.waitUntilElementNotVisible('#course-details-modal');
// Get and check the title of last entry
var entries = element.all(by.css('li.entry-title div div a'));
expect(entries.last().getText()).toContain('New testing entry title');
});
});
});
});
});