views:

2332

answers:

6

The following instruction

Selenium.typeKeys("location", "gmail.com");

types the string gmailcom instead of gmail.com.

What's happening there?

From the comments:
I am trying to simulate autofill and the only way to do it currently on selenium is to combine type and typeKeys. eg:

selenium.type("assigned_to", split[0]+"@");
selenium.typeKeys("assigned_to", "gmail.com");

Now my question is why typeKeys doesn't type the 'dot' in between gmail.com?

+2  A: 

Use the type method.

From the javadoc for typekeys:

this command may or may not have any visible effect, even in cases where typing keys would normally have a visible effect

...

In some cases, you may need to use the simple "type" command to set the value of the field and then the "typeKeys" command to send the keystroke events corresponding to what you just typed.

Alex B
Believe me i read that doc. I am trying to simulate autofil and the only way to do it currently on selenium is to combine type and typeKeys. eg:selenium.type("assigned_to", split[0]+"@");selenium.typeKeys("assigned_to", "gmail.com");Now my question is why typeKeys doesnt type the 'dot' in between gmail.com?
Afamee
I added your comment to your question. Comments aren't read by everyone.
furtelwart
+2  A: 

Have you tried using the Native key functions and javascript char codes? I couldn't get a 'period' character to work using them (char 190), but I got the decimal (char 110) to work just fine, and the text box shouldn't have a problem with either.

selenium.Focus("assigned_to");
selenium.Type("assigned_to", split[0]+"@");
selenium.TypeKeys("assigned_to", "gmail");
selenium.KeyPressNative("110");
selenium.TypeKeys("assigned_to", "com");
s_hewitt
I couldn't find any function in selenium that types a period (ASCII 46).
s_hewitt
A: 

I'm also seeing this behaviour when using Selenium RC (C#), and with different characters ('y' for example which also seems to remove the character follow it from the typing action..)

For some situations it is entirely possible to get around the issue by typing out the keys with the TypeKeys or KeyPress functions, but I haven't managed to find a solution that works when you want to type text in a field, enter control characters ([Enter] or a newline for example), and then type more text.. (using the 'Type' function in this case simply overwrites the field contents...).

If anyone manages to find a reasonable solution to this issue, please add it to this question as it's starting to come up in google now and would probably help alot of people out.. (I'd start a bounty if I could..)

Peter Bernier
A: 

This is an open bug in Selenium (bug SEL-519).

After some fiddling around with it, I finally managed to enter '.' into a textarea by using JavaScript. Execute something like window.document.getElementById('assigned_to').value += '.' via storeEval or the like.

A: 

I got the same behaviour but fixed it by passing a variable to the Type command instead of a string.

string email = @"[email protected]";
selenium.Type(inputfield, email);

It works like a charm!

Oscar
Thats because you are using the Type method, the problem in the question is with the TypeKeys method.
Sam Warwick
A: 

Hi, but this is not a problem of .(period symbol),even i am using this typeKeys() and tried to write a string like "Hi, can you send me more details?" and during execution i found it's typing like "Hi, can u send me more details". here i found two things trim some text and ? symbol.

Ambrish kumar