Skip to content

Commit

Permalink
Updating missed .NET test for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
jimevans committed Jul 12, 2019
1 parent 0eafd9e commit d829459
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions dotnet/test/common/Interactions/CombinedInputActionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.ObjectModel;
using System.Drawing;
using System.Runtime.InteropServices;

namespace OpenQA.Selenium.Interactions
{
Expand Down Expand Up @@ -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();

Expand All @@ -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"));
Expand All @@ -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();

Expand Down Expand Up @@ -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;

Expand All @@ -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();

Expand All @@ -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();
Expand Down

0 comments on commit d829459

Please sign in to comment.