Selenium 为什么要在量角器中计算()?
当我运行下面的代码段时,我得到了以下输出。但我仍然不清楚为什么以及何时必须使用evaluate()Selenium 为什么要在量角器中计算()?,selenium,selenium-webdriver,protractor,angularjs-e2e,Selenium,Selenium Webdriver,Protractor,Angularjs E2e,当我运行下面的代码段时,我得到了以下输出。但我仍然不清楚为什么以及何时必须使用evaluate() browser.get('https://weather.com/en-IN'); $$("input[data-ng-change='goSearch()']").evaluate('placeholderText').then(function(value) { console.log(value); }); 很少使用,但有一个独特的用途-它使您
browser.get('https://weather.com/en-IN');
$$("input[data-ng-change='goSearch()']").evaluate('placeholderText').then(function(value) {
console.log(value);
});
很少使用,但有一个独特的用途-它使您能够访问当前正在使用的元素的范围。当您要查找的值没有作为属性或元素文本在HTML中公开时,通常需要这样做
例如,如果在对象数组上有一个中继器,并且需要访问HTML中不存在的某些对象属性:
element.all(by.repeater("address in addresses")).filter(function (elm) {
return elm.evaluate("address.zipCode").then(function (zipCode) {
return zipCode === "10801";
});
});
evaluate()
方法用于获取控制器内任何$scope变量的值。