Issue Details (XML | Word | Printable)

Key: SEL-671
Type: Bug Bug
Status: Open Open
Priority: Critical Critical
Assignee: Andras Hatvani
Reporter: Sascha Schwarze
Votes: 4
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Selenium

_fireEventOnElement ignores shift/alt/ctrl/meta key setting

Created: 27/May/09 07:21 AM   Updated: 11/Jul/09 07:53 AM
Component/s: BrowserBot-IE, BrowserBot-Konqueror, BrowserBot-Safari
Affects Version/s: 1.0-beta-2
Fix Version/s: None

File Attachments: 1. Text File SEL-671.patch (5 kB) 09/Jul/09 03:41 PM - Sascha Schwarze
2. Zip Archive shift-_fireEventOnElement.zip (1 kB) 27/May/09 07:21 AM - Sascha Schwarze

Environment: Windows, IE


 Description  « Hide

Description
===========
Selenium has methods like shiftKeyDown to control the setting of these keys. Using this works fine in Firefox but fails in Internet Explorer.

Steps to reproduce
==================
1. Download the ZIP File.
2. Import the Java file to your Eclipse
3. Start Selenium Server on port 4444
4. Run the test case (it will do a click without and with shift key pressed - if shift is pressed a text is changed, this is verified)
-> It will do the same test on both Firefox and Internet Explorer, Firefox will pass, IE will fail.

Expected
========
The test case should pass because the second click changes the text.

Actual
======
The test case fails because in Internet Explorer the second click is done without shift.

Solution
======
The error is in selenium-browserbot.js. The function _fireEventOnElement is platform specific. In IEBrowserBot, SafariBrowserBot and KonquerorBrowserBot there is an if clause:

if (element[eventType]) { element[eventType](); }
else { this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY); }

Because element[eventType] is defined it is directly called. In this case the keys are not handled. I changed this condition to:

if (element[eventType] && !this.browserbot.altKeyDown && !this.browserbot.controlKeyDown && !this.browserbot.shiftKeyDown) { element[eventType](); } }
else { this.browserbot.triggerMouseEvent(element, eventType, true, clientX, clientY); }

This checks if one of the keys Alt, Ctrl or Shift is pressed. In this case it uses the triggerMouseEvent case. For Safari I assume that also the Meta Key has to be checked but as I do not have an Apple here (and also no Konqueror) I am unable to verify this.



Sort Order: Ascending order - Click to sort in descending order
Sascha Schwarze added a comment - 09/Jul/09 03:41 PM

Attaching patch for this problem, including test case.

Personally I tested it on IE8, Opera, Google Chrome and FF3.