I have a long string to test and sendKeys() takes too long. When I tried to set the value of the text the program crashes. I know the Selenium sendKeys() is the best way to test the actual user input, but for my application it takes too much time so I am trying to avoid it.
Is there a way to set the value right away?
See this quick example:
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
// find the search input field on google.com
inputField = driver.findElement(webdriver.By.name('q'));
var longstring = "test"; // not really long for the sake of this quick example
// this works but is slow
inputField.sendKeys(longstring);
// no error but no values set
inputField.value = longstring;
// Output: TypeError: Object [object Object] has no method 'setAttributes'
inputField.setAttributes("value", longstring);
sendKeyswould be to set the value of theinputDOM element directly. However, you show only fragment of how you try to do it and you don't explain how the program "crashes" exactly. ("Crashes" is not precise at all.)inputgets a value. You do show howinputFieldgets a value but notinput, which is a different variable.inputFieldthroughout. With.value = longstringthe program executes fine, but doesn't actually set the value.