SeleniumHQ / selenium-google-code-issue-archive

Archive, please see main selenium repo
https://github.com/seleniumhq/selenium
345 stars 195 forks source link

WebDriverCommandProcessor is not processing "type" command consistent with Server and IDE #1982

Closed lukeis closed 8 years ago

lukeis commented 8 years ago

Originally reported on Google Code with ID 1982

When executing a test with the WebDriverCommandProcessor, if you "type" a string to
a textarea, the textarea is filled with that string. All other content is removed from
that field.

Note that this works okay for normal <input> fields.

Since 2.0rc2, the context of a textarea is no longer cleared and content is appended.
This is not correct, since both Selenium IDE and Selenium server replace the content.

What steps will reproduce the problem?
1. Test attached unit test with Selenium 2.0b3, this will pass
2. Test the same with Selenium Selenium 2.0rc3, this will fail

What is the expected output? What do you see instead?

It would be expected that the WebDriverCommandProcessor mimics the Selenium (Selenese)
command set as much as possible.

Selenium version: 2.0rc3
OS: Max OS X 10.6.7
Browser: Firefox
Brower version: 3.6 and 5 (which is only supported through Se 2.0rc3)

Reported by gaphor on 2011-07-04 17:09:50


lukeis commented 8 years ago
This problem is still exposed in Selenium 2.7.

Reported by gaphor on 2011-10-06 18:57:28

lukeis commented 8 years ago
The commit leading to this problem is:

    SimonStewart: There seems to be an odd problem when emulating 'type' into a rich
text area. 
    Falling back to using sendKeys directly
    https://selenium.googlecode.com/svn/trunk@12156

This patch adds an extra clear() command to ensure the text area is cleared before
text is added.

Reported by gaphor on 2011-10-06 20:37:35


lukeis commented 8 years ago
Calling clear before sendKeys may have side effects when you have blur/focus handlers.
I don't think that this is a good general solution.

In our case, sending Ctrl+A / Cmd+A to select the field's content before the "real"
sendKeys worked reliably.

Reported by mguillemot@yahoo.fr on 2011-10-07 06:22:04

lukeis commented 8 years ago
Main issue is that the current selenium emulation is inconsistent with the behavior
in Selenium IDE. 

I suppose sending a ctrl-A / cmd-A can solve this just as well, although I'm not sure
how that can be achieved.

Are those events fired by the native browser (e.i. out of control of selenium?)

Reported by gaphor on 2011-10-07 07:44:11

lukeis commented 8 years ago

Reported by barancev on 2011-10-13 06:01:32

lukeis commented 8 years ago
The WebDriverBackedSelenium is provided as a tool for allowing teams to migrate from
RC to WebDriver, not as a perfect replacement (though we do try and be correct). I've
put in a temporary fix that may work, but the best advice would be to do something
like:

WebDriver driver = ((WrapsDriver) selenium).getWrappedDriver();
WebElement element = driver.findElement(By.id("foo"));
element.clear();
element.sendKeys("Your text here");

Reported by simon.m.stewart on 2012-02-20 22:11:55

lukeis commented 8 years ago
This issue was closed by revision r15931.

Reported by simon.m.stewart on 2012-02-20 22:12:47

lukeis commented 8 years ago

Reported by luke.semerau on 2015-09-17 18:13:10