javascript - Selenium - {[[PromiseStatus]] : "pending"} has no method 'indexOf'

标签 javascript selenium selenium-webdriver mocha.js

我完全理解需求正在发生,但找不到解决该问题的方法。 这是代码:

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/

相关文章:

javascript - 在 jQuery 中为论坛设置按钮格式

javascript - 响应式图像网格修复

javascript - 如何删除 "chrome is being controlled by automated test software"selenium javascript

javascript - 渲染动态 html 后, Angular click() 事件不起作用

javascript - 关于代码执行和javascript阻塞/非阻塞性质的问题

java - Selenium 2 WebDriver NoClassDefFoundErrorS

python - driver.page_source 使用 Selenium 仅返回元名称 ="ROBOTS"内容 ="NOINDEX, NOFOLLOW"

python - 尝试下载文件时,使用 Python 的 Headless Chrome 会暂停

java sendkeys 错误键应该是一个字符串

selenium - Play framework + Selenium webdriver + cucumber sticks on the first http request