1

As both of them do the same activity is there any special differences between type and typekeys in selenium webdriver.

wdBacked.type(locator, value);

wdBacked.typeKeys(locator, value);
  • 1
    Selenium JavaDoc makes some differentiation: release.seleniumhq.org/selenium-remote-control/1.0-beta-2/doc/…. It says "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.". Would be interesting to see what they mean by "some cases"... – dzieciou Mar 1 '14 at 12:39
3
type

void type(java.lang.String locator, java.lang.String value) Sets the value of an input field, as though you typed it in.

Inputs the value. Sets the textfield to the value, nothing special. It just takes the entire string and puts it in there at one time.

typeKeys

void typeKeys(java.lang.String locator, java.lang.String value) Simulates keystroke events on the specified element, as though you typed the value key-by-key.

Simulates each keystroke. So if the page has an action that occurs as you type (for example, google's autosuggest), this will be the action you would need. There is also other places where this may be useful but not too many overall.

They are very similar and generally speaking your going to want to use type unless you need to simulate each keystrokes for a reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.