本文介紹了量角器測試:如何設置登錄表單中文本元素的值?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在 Protractor 中為 Angular 應用程序編寫測試.我想填寫登錄表單并提交.
I am writing tests in Protractor for an Angular app. I want to fill out a login form and submit it.
我該怎么做?我已經做到了這一點,但我不知道如何設置電子郵件和密碼字段的值.
How can I do this? I have got this far, but I don't know how to set the value of the email and password fields.
describe('The dashboard', function() {
ptor = protractor.getInstance();
beforeEach(function() {
ptor.get('#/dashboard');
var email = ptor.findElement(protractor.By.model('email'));
var password = ptor.findElement(protractor.By.model('password'));
var submit = ptor.findElement(protractor.By.tagName('button'));
// Fill out the form?
submit.click();
});
it('has a heading', function() {
heading = ptor.findElement(protractor.By.tagName('h1'));
expect(heading.getText()).toEqual('My Dashboard');
});
});
推薦答案
只是為了任何通過谷歌找到這個的人的利益,答案是:
Just for the benefit of anyone who found this via Google, the answer is:
email.sendKeys('myemail@myemail.com');
password.sendKeys('mypassword');
這篇關于量角器測試:如何設置登錄表單中文本元素的值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!