Maya
Maya

Reputation: 7203

Having issue typing in text in textbox using Selenium Webdriver sendkeys

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?

enter image description here

Upvotes: 1

Views: 6640

Answers (3)

user9797980
user9797980

Reputation:

Actions a = new Actions(driver);
a.SendKeys(element, "Your Text").Build().Perform();

Upvotes: 0

Nora
Nora

Reputation: 1482

Have you tried this? You shouldn't have to click and backspace.

element.clear();
element.sendKeys("Joe");

Upvotes: 3

allergic
allergic

Reputation: 392

try this new Actions(driver).moveToElement(element).click().perform();

Upvotes: 0

Related Questions