我很努力地获取文本框的实际文本,因为我需要它作为文本存储在变量中,而不是将其与值进行比较,因为我需要将其添加到URL的末尾以调用另一个页面。如何获得selenium webdriver中的文本框的值,Js
我试图使用ebeal建议的代码,但它并没有做什么,我想:
var access_token = driver.findElement(webdriver.By.name("AccToken"))
.getAttribute("value")
.then(console.log);
// This outputs the right result but only to the console as I can't save it to a variable
var access_token = driver.findElement(webdriver.By.name("AccToken"))
.getText();
access_token = access_token.then(function(value){
console.log(value);
});
console.log("the new one : " + access_token);
// this one outputs : the new one: Promise::304 {[[PromiseStatus]]: "pending"}
任何想法?