Reputation: 1672
I need to preface this with "I am a noob".
In WatiN
I was able to use sendText("text");
which would send the whole text rather than typing it out one character at a time which is what sendKeys()
does. I have looked quite a bit for a sendText()
option in Selenium and cannot seem to find anything which works.
Is there a sendText()
option for selenium, if so could you provide a code example?
Upvotes: 3
Views: 725
Reputation: 38444
In Selenium RC (the older JavaScript-fueled Selenium that is no longer actively developed), there is the type()
method.
In WebDriver (also known as Selenium 2), there's no such thing. However, you can easily emulate it via JavaScript:
// only if your driver supports JavaScript
JavascriptExecutor js = (JavascriptExecutor)driver;
WebElement elem = driver.findElement(By.whatever("something"));
js.executeScript("arguments[0].value = 'some text'", elem);
Upvotes: 1