【发布时间】:2019-10-25 08:58:48
【问题描述】:
所以我可以记录我的 Cookie 和 URL,但我无法尝试将它们设置为变量,请帮助。
我将它们都设置为变量,我只会得到 Promise { }
的输出driver.findElement(webdriver.By.xpath(`//*[@id="SIZE"]/option[2]`)).click();
driver.findElement(webdriver.By.xpath(`//*[@id="trackpants-ink"]/div/div[3]/form[1]/input[3]`)).click();
setTimeout(function(){
driver.findElement(webdriver.By.xpath(`//*[@id="js-wrap"]/header/div[2]/form/div/div/div[2]/input`)).click();
setTimeout(function() {
driver.getCurrentUrl().then(url=> console.log(url)).catch(err=>console.log(err));
setInterval(function() {
driver.manage().getCookies().then(function (cookies) {
console.log(cookies);
});
}, 2000);
}, 2000);
}, 5000);
}
我想将它设置为一个变量(这是 cookie)
driver.manage().getCookies().then(function (cookies) {
console.log(cookies);
});
我想将它设置为一个变量(这是 URL)
driver.getCurrentUrl().then(url=> console.log(url)).catch(err=>console.log(err));
这两个都在运行时输出到控制台,但它不允许我将它们转换为变量。 感谢您的帮助:)
【问题讨论】:
标签: javascript node.js selenium selenium-webdriver fs