qui*_*eam 3 javascript selenium selenium-webdriver
那里有一个类似的问题(Python 中的一个较旧的问题),但这个问题与 JS 有关。在 NodeJS、Mocha 环境中使用 Selenium 进行测试。我想做的是单击 Bootstrap 下拉列表并检查 HTML 以查找更改。我尝试过以下方法:
test.it('should click on all header links',
function() {
var elem = driver.findElement(By.id('Profile'));
console.log(elem.getAttribute('innerHTML'));
console.log(elem.getInnerHtml());
});
Run Code Online (Sandbox Code Playgroud)
两个调用都返回相同的内容。
{ then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending] }
Run Code Online (Sandbox Code Playgroud)
我计划将 HTML 提供给cheerio,以便我可以检查结构更改。感谢对此的任何帮助。
我能够通过执行以下操作以字符串形式检索 HTML。
driver.findElement(By.id('Profile')).getAttribute("innerHTML").then(function(profile) {
console.log(profile);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5213 次 |
| 最近记录: |