试图从selenium-webdriver中的getAttribute()获取字符串值

时间:2017-07-17 14:17:42

标签: javascript node.js selenium selenium-webdriver chai

我试图获取元素属性data-id的字符串值并将其存储到变量中

这样我就可以检查以确保data-id等于下一页上加载的var dataId; it('Should redirect to request details page, with the selected contract', function(done) { driver.wait(until.elementLocated(by.xpath('//*[@id="contracts-list-panel"]/div[2]/div'))).click(); var element = driver.findElement(by.xpath('//*[@id="select-contract-modal"]/div[1]/div[2]/button')); dataId = element.getAttribute("data-id").then(function(attr) { expect(typeof attr).to.be.a("string"); console.log(dataId.toString()); element.click().then(function() { driver.wait(until.elementLocated(by.id('request-new-signer-email'))).then(done()); }); }); });

**这是我的代码:

console.log

ManagedPromise::1356 {[[PromiseStatus]]: "pending"} 会返回此信息:

1)

0 个答案:

没有答案