Updating missed .NET test for MacOS
using System;
using System.Collections.ObjectModel;
using System.Drawing;
+using System.Runtime.InteropServices;
namespace OpenQA.Selenium.Interactions
{
@@ -80,18 +81,23 @@ public void ShiftClickingOnMultiSelectionList()
[Test]
[IgnoreBrowser(Browser.IE, "IE reports [0,0] as location for <option> elements")]
- [IgnoreBrowser(Browser.Safari, "Control + click in macOS results in context menu, not multiselect.")]
public void ControlClickingOnMultiSelectionList()
{
+ string controlModifier = Keys.Control;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ controlModifier = Keys.Command;
+ }
+
driver.Url = formSelectionPage;
ReadOnlyCollection<IWebElement> options = driver.FindElements(By.TagName("option"));
Actions actionBuider = new Actions(driver);
IAction selectThreeOptions = actionBuider.Click(options[1])
- .KeyDown(Keys.Control)
+ .KeyDown(controlModifier)
.Click(options[3])
- .KeyUp(Keys.Control).Build();
+ .KeyUp(controlModifier).Build();
selectThreeOptions.Perform();
@@ -105,6 +111,12 @@ public void ControlClickingOnMultiSelectionList()
[Test]
public void ControlClickingOnCustomMultiSelectionList()
{
+ string controlModifier = Keys.Control;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ controlModifier = Keys.Command;
+ }
+
driver.Url = selectableItemsPage;
IWebElement reportingElement = driver.FindElement(By.Id("infodiv"));
@@ -113,11 +125,11 @@ public void ControlClickingOnCustomMultiSelectionList()
ReadOnlyCollection<IWebElement> listItems = driver.FindElements(By.TagName("li"));
- IAction selectThreeItems = new Actions(driver).KeyDown(Keys.Control)
+ IAction selectThreeItems = new Actions(driver).KeyDown(controlModifier)
.Click(listItems[1])
.Click(listItems[3])
.Click(listItems[5])
- .KeyUp(Keys.Control).Build();
+ .KeyUp(controlModifier).Build();
selectThreeItems.Perform();
@@ -232,17 +244,11 @@ public void MouseMovementWorksWhenNavigatingToAnotherPage()
[Test]
public void ChordControlCutAndPaste()
{
- // FIXME: macs don't have CONRTROL key
- //if (getEffectivePlatform().is(Platform.MAC)) {
- // return;
- //}
-
- //if (getEffectivePlatform().is(Platform.WINDOWS) &&
- // (isInternetExplorer(driver) || isFirefox(driver))) {
- // System.out.println("Skipping testChordControlCutAndPaste on Windows: native events library" +
- // " does not support storing modifiers state yet.");
- // return;
- //}
+ string controlModifier = Keys.Control;
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ controlModifier = Keys.Command;
+ }
driver.Url = javascriptPage;
@@ -259,7 +265,7 @@ public void ChordControlCutAndPaste()
//TODO: Figure out why calling sendKey(Key.CONTROL + "a") and then
//sendKeys("x") does not work on Linux.
- new Actions(driver).KeyDown(Keys.Control)
+ new Actions(driver).KeyDown(controlModifier)
.SendKeys("a" + "x")
.Perform();
@@ -268,7 +274,7 @@ public void ChordControlCutAndPaste()
Assert.AreEqual(string.Empty, element.GetAttribute("value"));
- new Actions(driver).KeyDown(Keys.Control)
+ new Actions(driver).KeyDown(controlModifier)
.SendKeys("v")
.SendKeys("v")
.Perform();
