Ignoring spaces in text input

236 views
Skip to first unread message

ni...@iforsikring.dk

unread,
Dec 1, 2014, 7:11:28 AM12/1/14
to seleniu...@googlegroups.com

I'm trying to write a name (string with spaces) into an input field, but it seems to ignore the space between the first and last name, which is quite important in this instance. Have anybody else experienced similar problems?

My code:

#write given message to element specified by name
def write_to_input(self,name,message):
    inputEl = self.driver.find_element_by_name(name)
    inputEl.send_keys(message)

#writing name
self.write_to_input("name","John Doe")

Rajeev Prabhakaran Nair

unread,
Dec 3, 2014, 4:24:04 AM12/3/14
to seleniu...@googlegroups.com
Hi,

Since it parses as string it will not omit the spaces.

Can you clear that field before inputting something to the field. Also you can do something Store in another variable and use that variable to put the value.
("name", variable). Also try to input the values manually into that field :)


self.write_to_input("name","John Doe")
Regards / Rajeev

jeevan

unread,
Dec 3, 2014, 10:44:58 AM12/3/14
to seleniu...@googlegroups.com
I have experienced the similar issue but space was replaced with % symbol. It happened because the input element was "hidden" but in your case hope its not hidden.

I tried with Javascript and it did worked. WebDriver types the text but not with space, so use Javascript.
If WebDriver is not working then try with JavaScriptExceutor and see, if it works or not.

Thanks,
Jeevan

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/2fb30ae0-477b-4787-b2c2-b49ebda6db28%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages