2016-03-01 19 views
1

我試圖建立量角器來測試我的應用程序,但它通過Gmail要求身份驗證的ID,和我卡在嘗試登錄:量角器找不到Gmail的輸入與密碼

describe('Vivace Home page', function() { 

    var hasClass = function (element, cls) { 
    return element.getAttribute('class').then(function (classes) { 
     return classes.split(' ').indexOf(cls) !== -1; 
    }); 
    }; 

    beforeEach(function() { 

    browser.ignoreSynchronization = true; 
    browser.get('/'); 

    var emailInput = browser.driver.findElement(by.id('Email')); 
    emailInput.sendKeys('[email protected]') 

    var nextButton = browser.driver.findElement(by.id('next')); 

    nextButton.click().then(function() { 
     browser.pause(); 
     var passwordInput = browser.driver.findElement(by.id('Passwd')); 
     console.log(passwordInput); 
     passwordInput.sendKeys('11111'); 
     // var signInButton = browser.driver.findElement(by.id('signIn')); 
    }) 
    }); 

    it('should have the correct title', function() { 
    expect(browser.getTitle()).toEqual('InRhythm - Vivace'); 
    }); 
}); 

我可以看到量角器打開gmail頁面,輸入電子郵件並單擊下一個按鈕,當我做browser.pause時,我可以在頁面上使用檢查器實際上看到帶有「Passwd」標識的密碼輸入,但是我無法訪問它來完成我的登錄。

當我刪除browser.pause時出現此錯誤

失敗:沒有這樣的元件:無法找到元素:{ 「方法」: 「ID」, 「選擇器」: 「的passwd」}

回答

2

等待它become visible

var EC = protractor.ExpectedConditions; 
var passwordInput = element(by.id('Passwd')); 

browser.wait(EC.visibilityOf(passwordInput), 5000); 
passwordInput.sendKeys('11111'); 
+0

即沒工作但EC.visibilityOf確實工作 – WinchenzoMagnifico

+0

@WinchenzoMagnifico好吧,很好,適當更新。謝謝! – alecxe