我完全理解需求正在发生,但找不到解决该问题的方法。 这是代码:
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()
显式解析promise:
text.then(function (textValue) {
textValue = fqdn + textValue.substring( textValue.indexOf("/parse_actions") );
driver.get(textValue);
});
关于javascript - Selenium - {[[PromiseStatus]] : "pending"} has no method 'indexOf' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32504759/