量角器测试:如何设置文本元素的值登录表单? [英] Protractor testing: How to set the value of text elements in a login form?

查看:148
本文介绍了量角器测试:如何设置文本元素的值登录表单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写在量角器测试的角度应用。我要填写一个登录表单并提交。

我怎样才能做到这一点?到目前为止,我已经得到了这一点,但我不知道如何设置的电子邮件和密码字段的值。

 描述(下称仪表盘,函数(){
  ptor = protractor.getInstance();  beforeEach(函数(){
    ptor.get('#/仪表盘);
    VAR电子邮件= ptor.findElement(protractor.By.model(电子邮件));
    VAR密码= ptor.findElement(protractor.By.model('密码'));
    VAR提交= ptor.findElement(protractor.By.tagName('按钮'));
    // 填写表格?
    submit.click();
  });  它('有一个标题',函数(){
    标题= ptor.findElement(protractor.By.tagName(H1));
    期待(heading.getText())toEqual(我的仪表盘)。
  });
});


解决方案

只是为了任何人谁通过谷歌发现这样做的好处,答案是:

  email.sendKeys('myemail@myemail.com');
password.sendKeys('输入mypassword');

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

这篇关于量角器测试:如何设置文本元素的值登录表单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆