2

我有由中继器选择的元素选择器。我正进入(状态

$186
Cost

element.getText().then(function (balance) {
          console.log(balance);
        });

我只需要选择 186 美元,我试图通过使用first();该元素来获得。和余额[0]。但没有找到解决方案。请建议。

4

2 回答 2

1

如果元素存在于 DOM 中,如下所示:

<span ng-repeat="record in records">$186</span><span ng-repeat="record in records">Cost</span>

然后下面的代码工作:

element.all(by.repeater('record in records')).get(0).getText().then(function(txt) {
    console.log('txt:'+txt);
});
于 2017-11-02T15:42:03.227 回答
0

从字符串中的元素存储中获取文本后。找到所需的子字符串,因为您知道该模式。

var res = str.substring(0, 4);//Change as per the pattern or use regex if required.
于 2017-11-03T00:55:47.763 回答