<a id="compareCompanies" b:onclick="needsController.showQuotes = true;" href="#">Compare companies</a>
使用Mocha的Selenium Webdriver JavaScript代码:
driver.wait(function () {
driver.findElement(webdriver.By.id("compareCompanies"));
}, 5000);
var compareCompaniesLink = driver.findElement(webdriver.By.id("compareCompanies"));
compareCompaniesLink.click();
我得到的错误是:
NoSuchElementError:无法找到元素:{&#34;方法&#34;:&#34; CSS 选择&#34;&#34;选择器&#34;:&#34; * [ID = \&#34; compareCompanies \&#34;]&#34;}
答案 0 :(得分:0)
似乎错误就在这里:
原文:
var compareCompaniesLink = driver.findElement(webdriver.By.id("compareCompanies"));
更新:
var compareCompaniesLink = driver.findElement(By.id("compareCompanies"));