Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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);
share|improve this question
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 at 12:39

1 Answer 1

up vote 3 down vote accepted
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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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