input text readonly

674 views
Skip to first unread message

Ferawati Hartanti Pratiwi

unread,
Oct 21, 2016, 1:06:37 AM10/21/16
to robotframework-users
Hi,
I have a problem with readonly element..
I have an element <input id="date" class="date" placeholder="dd/mm/yy" readonly="" value="" data-parsley-id="4" type="text"> an input for a date

I've tried to evolve a method from resource https://groups.google.com/forum/#!topic/robotframework-users/u2kCnXuzWJw
${element}= set variable xpath=//input[@id='date' and @class='date']
Mouse Over ${element}
Execute JavaScript return window.document.getElementById('${element}').readOnly = false
Input Text ${element} 13/11/2016

but it didnt work..its show WebDriverException: Message: JavaScript error
anyone has an experience with a readonly element robot framework?? please help thank you very much

Hélio Guilherme

unread,
Oct 21, 2016, 3:55:35 AM10/21/16
to ferawati...@gmail.com, robotframework-users
If the element is read-only, then the real user could not input text into it. Since Selenium tries to simulate user actions, it would not be allowed to input text.

Have you tried other strategies to make the element writable? Like `Click Element`?



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Ferawati Hartanti Pratiwi

unread,
Oct 21, 2016, 4:02:15 AM10/21/16
to robotframework-users, ferawati...@gmail.com
I've tried but if there is another way except Click Element..because I want to input the date with current date so Click Element kind of inflexible I think..

On Friday, October 21, 2016 at 2:55:35 PM UTC+7, Hélio Guilherme wrote:
If the element is read-only, then the real user could not input text into it. Since Selenium tries to simulate user actions, it would not be allowed to input text.

Have you tried other strategies to make the element writable? Like `Click Element`?


On Fri, Oct 21, 2016 at 4:06 AM, Ferawati Hartanti Pratiwi <ferawati...@gmail.com> wrote:
Hi,
I have a problem with readonly element..
I have an element <input id="date" class="date" placeholder="dd/mm/yy" readonly="" value="" data-parsley-id="4" type="text"> an input for a date

I've tried to evolve a method from resource https://groups.google.com/forum/#!topic/robotframework-users/u2kCnXuzWJw
${element}= set variable xpath=//input[@id='date' and @class='date']
Mouse Over ${element}
Execute JavaScript return window.document.getElementById('${element}').readOnly = false
Input Text ${element} 13/11/2016

but it didnt work..its show WebDriverException: Message: JavaScript error
anyone has an experience with a readonly element robot framework?? please help thank you very much

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.

Tatu Aalto

unread,
Oct 21, 2016, 5:42:43 AM10/21/16
to ferawati...@gmail.com, robotframework-users

Ugh

I actually run in to the same problem today. The error is caused by the selenium being picky but error is raised when element is cleared. Input Text keyword will do this:

element = driver.find_by_xpath("//path/to/element")
element.clear()  # exception is raised here
element.send_keys("some text")

But this works:
element = driver.find_by_xpath("//path/to/element")
element.send_keys("some text")

There could be some justification to keep input as read only for security reasons. But if you are happy with the above solution, one can turn the code to a keyword. Example this could work:

from robot.libraries.BuiltIn import BuiltIn

def send_keys(xpath, text):
    s2l = BuiltIn().get_library_instance('Selenium2Library')
    driver = s2l._current_browser()
    element = driver.find_by_xpath(xpath)
    element.send_keys(text)

Please note that the code is written out of my memory and is untested.

-Tatu
Send from my mobile


On 21 Oct 2016 11:02 a.m., "Ferawati Hartanti Pratiwi" <ferawati...@gmail.com> wrote:
I've tried but if there is another way except Click Element..because I want to input the date with current date so Click Element kind of inflexible I think..

On Friday, October 21, 2016 at 2:55:35 PM UTC+7, Hélio Guilherme wrote:
If the element is read-only, then the real user could not input text into it. Since Selenium tries to simulate user actions, it would not be allowed to input text.

Have you tried other strategies to make the element writable? Like `Click Element`?


On Fri, Oct 21, 2016 at 4:06 AM, Ferawati Hartanti Pratiwi <ferawati...@gmail.com> wrote:
Hi,
I have a problem with readonly element..
I have an element <input id="date" class="date" placeholder="dd/mm/yy" readonly="" value="" data-parsley-id="4" type="text"> an input for a date

I've tried to evolve a method from resource https://groups.google.com/forum/#!topic/robotframework-users/u2kCnXuzWJw
${element}= set variable xpath=//input[@id='date' and @class='date']
Mouse Over ${element}
Execute JavaScript return window.document.getElementById('${element}').readOnly = false
Input Text ${element} 13/11/2016

but it didnt work..its show WebDriverException: Message: JavaScript error
anyone has an experience with a readonly element robot framework?? please help thank you very much

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.

To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.

Kevin O.

unread,
Oct 21, 2016, 9:12:41 AM10/21/16
to robotframework-users
Not sure it works in newer versions, but Press Key used to send whatever text you fed it. Not just one letter. So I've used it to skip the clearing part in the past.

Ferawati Hartanti Pratiwi

unread,
Oct 24, 2016, 6:13:26 AM10/24/16
to robotframework-users
Press Key keyword really can use for a readonly element? I dont try it yet. but thank you I'll try it..
Reply all
Reply to author
Forward
0 new messages