當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript by.id方法代碼示例

本文整理匯總了TypeScript中protractor/globals.by.id方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript by.id方法的具體用法?TypeScript by.id怎麽用?TypeScript by.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在protractor/globals.by的用法示例。


在下文中一共展示了by.id方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

  it('should log in', () => {

    // Check browser url (root)
    expect(browser.driver.getCurrentUrl()).toMatch('/');

    // Find form elements (login modal is already opened)
    var userNameField = browser.driver.findElement(by.id('email'));
    var userPassField = browser.driver.findElement(by.id('password'));

    // Fill input fields
    userNameField.sendKeys(userEmail);
    userPassField.sendKeys(userPass);

    // Ensure fields contain what has been entered
    expect(userNameField.getAttribute('value')).toEqual(userEmail);
    expect(userPassField.getAttribute('value')).toEqual(userPass);

    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();

        // Browser url must have changed to the dashboard route
        expect(browser.driver.getCurrentUrl()).toMatch('/courses');
      });
    });
  });
開發者ID:pabloFuente,項目名稱:full-teaching,代碼行數:27,代碼來源:app.e2e-spec.ts

示例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();
          });
        });
      });
開發者ID:pabloFuente,項目名稱:full-teaching,代碼行數:30,代碼來源:app.e2e-spec.ts

示例3: toggleDropdown

 toggleDropdown() {
     return element.all(by.id('dropdownMenu1')).click();
 }
開發者ID:JonZeolla,項目名稱:incubator-metron,代碼行數:3,代碼來源:sensor-list.po.ts


注:本文中的protractor/globals.by.id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。