Using sendKeys in a readonly WebElement

4,393 views
Skip to first unread message

pablomarcelo

unread,
Sep 21, 2011, 1:11:38 PM9/21/11
to Selenium Users, pabl...@hotmail.com
I'm using WebDriver and I need to write some data in a readonly
textbox, I'm using sendKeys but it is not working.

Someone can explain me how to send data into a readonly textbox?

Thanks

Luke Inman-Semerau

unread,
Sep 21, 2011, 1:27:11 PM9/21/11
to seleniu...@googlegroups.com, pabl...@hotmail.com
You'll have to use the JavaScript Executor:
(Assuming your previous code looked like - element.sendKeys("my text to put in the value"); )

((JavascriptExecutor)driver).executeScript("arguments[0].value=arguments[1]", element, "my text to put in the value");

By default WebDriver behaves like an end user... if you can't do it manually, then WebDriver won't do it through the normal api.


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/selenium-users?hl=en.


Pablo Herrera

unread,
Sep 21, 2011, 1:44:18 PM9/21/11
to seleniu...@googlegroups.com, pabl...@hotmail.com
Thanks a lot.

2011/9/21 Luke Inman-Semerau <luke.s...@gmail.com>

Rituraj Singh

unread,
Sep 2, 2014, 1:58:49 AM9/2/14
to seleniu...@googlegroups.com, pabl...@hotmail.com
Thanks. Code is working fine for me :)

A Raza

unread,
Apr 17, 2021, 5:54:50 AM4/17/21
to Selenium Users
@Luke Inman-Semerau

Bravo, it worked for me too.

Thanks

Reply all
Reply to author
Forward
0 new messages