提问者:小点点

Pro拖拉机新手,收集Select选项有困难


自学量角器,解决非角度web应用程序的问题,并从选择控件中获取所有值的列表。这是html,但似乎无法验证列表。(该站点的第一个权重选择框)

http://halls.md/body-surface-area/bsa.htm

和我失败的语法。我的脚本成功执行引用了元素和选项,但无法正确评估列表中选项值的捕获:

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

共1个答案

匿名用户

首先,使用< code>element符号——至少看起来更整洁。

如果您想在控制台上看到选项文本或值,您需要解析promise:

var weightUnitSelect = element(by.name("wu"));
var options = weightUnitSelect.all(by.tagName("option"));

options.first().getText().then(function (text) {
    console.log(text);
});

此外,我建议抽象选择-

  • 选择-