Selenium - {[[PromiseStatus]]: "pending"} 没有方法 'indexOf'
Selenium - {[[PromiseStatus]]: "pending"} has no method 'indexOf'
我完全理解需求正在发生,但找不到解决该问题的方法。
这是代码:
el = driver.findElement(By.css('#mailmillieu a'));
text = el.getAttribute("href");
text = fqdn + text.substring( text.indexOf("/parse_actions") );
driver.get(text);
这是错误消息:
TypeError: Object Promise::340 {[[PromiseStatus]]: "pending"} has no method 'indexOf'
我如何告诉 Selenium 等到 promise 完成或被拒绝?
您可以通过then()
显式解决承诺:
text.then(function (textValue) {
textValue = fqdn + textValue.substring( textValue.indexOf("/parse_actions") );
driver.get(textValue);
});
我完全理解需求正在发生,但找不到解决该问题的方法。 这是代码:
el = driver.findElement(By.css('#mailmillieu a'));
text = el.getAttribute("href");
text = fqdn + text.substring( text.indexOf("/parse_actions") );
driver.get(text);
这是错误消息:
TypeError: Object Promise::340 {[[PromiseStatus]]: "pending"} has no method 'indexOf'
我如何告诉 Selenium 等到 promise 完成或被拒绝?
您可以通过then()
显式解决承诺:
text.then(function (textValue) {
textValue = fqdn + textValue.substring( textValue.indexOf("/parse_actions") );
driver.get(textValue);
});