0

I'm using Selenium to perform testing on both Chrome and IE11 browsers. My goal is to select 2 rows from a table by press the Control and hold it (KeyDown) and then select the 2 rows and finally to release the Control key (KeyUp).

Here is how I init the InternetExplorerDriver:

var explorerOptions = new InternetExplorerOptions
{
 IgnoreZoomLevel = true,
 IntroduceInstabilityByIgnoringProtectedModeSettings = true,
 RequireWindowFocus = true,
 EnableNativeEvents = false
};

var driverService = InternetExplorerDriverService.CreateDefaultService("Path to IEDriverServer.exe");
driverService.HideCommandPromptWindow = true;
driver = new InternetExplorerDriver(driverService, explorerOptions);

Here is my C# code:

Actions actions = new Actions(driver);
actions.KeyDown(Keys.LeftControl);
foreach (var index in indexes)
{
 actions.Click(tableRows[index]);
}
actions.KeyUp(Keys.LeftControl).Build().Perform();

Note: I tried both LeftControl and Control and both gave the same result.

Any suggestions to fix it? Workarounds are also appreciated.

misticos
  • 718
  • 5
  • 22
Nadeem Bader
  • 163
  • 2
  • 9

1 Answers1

0

I believe Native Events are required for these to function so you will want to try your test again with them enabled.

In WebDriver advanced user interactions are provided by either simulating the Javascript events directly (i.e. synthetic events) or by letting the browser generate the Javascript events (i.e. native events). Native events simulate the user interactions better whereas synthetic events are platform independent, which can be important in Linux when alternative window managers are used, see native events on Linux. Native events should be used whenever it is possible.

https://github.com/SeleniumHQ/selenium/wiki/Advanced-User-Interactions

More info: https://stackoverflow.com/a/34796379/4540638

I would also suggest trying it with another webdriver/browser if possible as a way to test the code.

J.D. Cain
  • 639
  • 4
  • 16