[英]Angular testing: Protractor can't get input value
I'm new to Protractor..I think I understood the basic principles in spite of the lacking documentation, but I can't find a way to solve this problem. 我是Protractor的新手。我认为尽管缺乏文档我理解了基本原理,但我找不到解决这个问题的方法。
Given this code: 鉴于此代码:
ptor.findElement(protractor.By.input('canvas.description')).sendKeys('My description');
var description = ptor.findElement(protractor.By.input('canvas.description'));
expect(description.getText()).toEqual('My description');
I can see that the input gets the text it's inserting and the model updates with the same value, but the test failures 'cause description.getText() returns '' (empty string). 我可以看到输入获取它插入的文本,模型更新具有相同的值,但测试失败导致description.getText()返回''(空字符串)。
Is there a different way to catch values inside inputs? 是否有不同的方法来捕获输入中的值?
Thanks in advance. 提前致谢。
Apparently there is a quirk with Selenium WebDriver. 显然,Selenium WebDriver有一个怪癖。 See here.
看到这里。
Try: 尝试:
description.getAttribute('value');
Note, that getAttribute
returns a promise, so if you need to use this value somehow you'll have to use a then
clause: 请注意,
getAttribute
返回一个promise,因此如果您需要以某种方式使用此值,则必须使用then
子句:
description.getAttribute('value').then(function(value){
//Do something with value
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.