新量角器和难度是收集中选择选项 [英] New to Protractor and difficulty with collecting Select options
问题描述
自我教学量角器和无角的web应用程序,并让所有的值列表中出了选择控制的战斗问题。这里是HTML,但似乎无法验证列表。 (在这个网站首重选择框)
http://halls.md/body-surface-area/bsa.htm
和我的失败语法。我的脚本执行成功引用元素和选项,但不能正确评估列表选项值的捕获:
VAR tempstr = browser.driver.findElement(by.xpath('//选择[@名称=武]')); //获取所有选项
VAR tempstrs = tempstr.findElements(by.tagName('选项'));
的console.log(tempstrs [1]);
首先,使用元素
符号 - 至少会看起来更干净
如果你想在控制台上看到该选项的文本或值,你需要解决的承诺:
VAR weightUnitSelect =元素(by.name(吴));
VAR的选择= weightUnitSelect.all(by.tagName(选项));options.first()。gettext的()。然后(函数(文本){
的console.log(文本);
});
另外,我建议抽象的选择 - >选项HTML结构这个答案的帮助:
self teaching protractor and fighting issues of non angular web app and getting the list of all values out of a select control. here is the html but can't seem to validate the list. (first weight select box at this site)
http://halls.md/body-surface-area/bsa.htm
and my failed syntax. my script executes successfully referencing the element and option but can't correctly evaluate the capture of option values in the list:
var tempstr = browser.driver.findElement(by.xpath('//select[@name="wu"]')); //get all the options
var tempstrs = tempstr.findElements(by.tagName('option'));
console.log(tempstrs[1]);
First of all, use element
notation - would at least look cleaner.
If you want to see the option text or value on the console, you need to resolve promises:
var weightUnitSelect = element(by.name("wu"));
var options = weightUnitSelect.all(by.tagName("option"));
options.first().getText().then(function (text) {
console.log(text);
});
Also, I recommend to abstract select->option HTML constructions with the help of this answer:
这篇关于新量角器和难度是收集中选择选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!