我有一个很长的字符串要测试,而且sendKeys()
花费的时间太长。当我试图设置text
程序崩溃的值时。我知道 SeleniumsendKeys()
是测试实际用户输入的最佳方式,但对于我的应用程序来说,它需要太多时间。所以我试图避免它。
有没有办法立即设置值?
请参阅此快速示例:
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);