当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Use sendKeys and store value in variable

问题描述:

Currently I'm using WebdriverJS and trying fill a form. My test is open form > fill the field with sendKeys and store this value for the variable. Follow my code:

driver.findElement(By.xpath("//a[contains(text(),'Añadir Propuesta Test')]")).click();

driver.wait(function () {

return driver.isElementPresent(By.css(".form-control.col-md-8"));

}, 15000);

var propuesta = driver.findElement(By.name('rut'));

propuesta.sendKeys('1111122222');

propuesta.getText().then(function(text){

console.log(text);

});

My actual result is returning empty value

How can I use sendKeys and store the same value sent?

网友答案:

The text you typed is stored in the value attribute:

propuesta.getAttribute('value').then(function(text){
    console.log(text);
});
分享给朋友:
您可能感兴趣的文章:
随机阅读: