Reputation: 7203
I am having an issue with typing text in a textbox using Selenium Webdriver.
I do the following:
element.clear();
element.click();
element.sendKeys(Keys.BACK_SPACE);
element.sendKeys("Joe");
and it types in "Joe", but it is grayed out, meaning it just clears the default value, and types instead of clicking on the textbox, and then typing it. When I manually type in "Joe", I click on the textbox so that the cursor is in the textbox, but element.click() does not do this for me.
Can anyone please suggest me a solution?
Upvotes: 1
Views: 6640
Reputation:
Actions a = new Actions(driver);
a.SendKeys(element, "Your Text").Build().Perform();
Upvotes: 0
Reputation: 1482
Have you tried this? You shouldn't have to click and backspace.
element.clear();
element.sendKeys("Joe");
Upvotes: 3
Reputation: 392
try this
new Actions(driver).moveToElement(element).click().perform();
Upvotes: 0