Skip to content

Commit

Permalink
Moving IE specific test to IE test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Sep 15, 2015
1 parent 2033029 commit 517c588
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,26 @@

package org.openqa.selenium.ie;

import static org.junit.Assert.assertEquals;
import static org.junit.Assume.assumeTrue;
import static org.openqa.selenium.WaitingConditions.elementTextToEqual;
import static org.openqa.selenium.ie.InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoDriverAfterTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;
import org.openqa.selenium.testing.NeedsLocalEnvironment;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.testing.TestUtilities;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import static org.junit.Assert.assertEquals;
import java.awt.*;

@NeedsLocalEnvironment(reason = "Requires local browser launching environment")
public class InternetExplorerDriverTest extends JUnit4TestBase {
Expand Down Expand Up @@ -51,6 +64,51 @@ public void canStartMultipleIeDriverInstances() {
}
}

@JavascriptEnabled
@NoDriverAfterTest
@NeedsLocalEnvironment
@Test
public void testPersistentHoverCanBeTurnedOff() throws Exception {
assumeTrue(TestUtilities.isInternetExplorer(driver));
// Destroy the previous driver to make sure the hovering thread is
// stopped.
driver.quit();

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ENABLE_PERSISTENT_HOVERING, false);
WebDriverBuilder builder = new WebDriverBuilder().setDesiredCapabilities(caps);
driver = builder.get();

try {
driver.get(pages.javascriptPage);
// Move to a different element to make sure the mouse is not over the
// element with id 'item1' (from a previous test).
new Actions(driver).moveToElement(driver.findElement(By.id("keyUp"))).build().perform();
WebElement element = driver.findElement(By.id("menu1"));

final WebElement item = driver.findElement(By.id("item1"));
assertEquals("", item.getText());

((JavascriptExecutor) driver).executeScript("arguments[0].style.background = 'green'", element);
new Actions(driver).moveToElement(element).build().perform();

// Move the mouse somewhere - to make sure that the thread firing the events making
// hover persistent is not active.
Robot robot = new Robot();
robot.mouseMove(50, 50);

// Intentionally wait to make sure hover DOES NOT persist.
Thread.sleep(1000);

wait.until(elementTextToEqual(item, ""));

assertEquals("", item.getText());

} finally {
driver.quit();
}
}

private WebDriver newIeDriver() {
return new WebDriverBuilder().get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@
import static org.openqa.selenium.WaitingConditions.elementTextToContain;
import static org.openqa.selenium.WaitingConditions.elementTextToEqual;
import static org.openqa.selenium.WaitingConditions.elementValueToEqual;
import static org.openqa.selenium.ie.InternetExplorerDriver.ENABLE_PERSISTENT_HOVERING;
import static org.openqa.selenium.support.ui.ExpectedConditions.not;
import static org.openqa.selenium.support.ui.ExpectedConditions.titleIs;
import static org.openqa.selenium.testing.Ignore.Driver.CHROME;
import static org.openqa.selenium.testing.Ignore.Driver.FIREFOX;
import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT;
import static org.openqa.selenium.testing.Ignore.Driver.IE;
import static org.openqa.selenium.testing.Ignore.Driver.MARIONETTE;
import static org.openqa.selenium.testing.Ignore.Driver.PHANTOMJS;
import static org.openqa.selenium.testing.Ignore.Driver.REMOTE;
import static org.openqa.selenium.testing.Ignore.Driver.SAFARI;
import static org.openqa.selenium.testing.TestUtilities.isFirefox;
Expand All @@ -51,19 +49,15 @@
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.Color;
import org.openqa.selenium.support.Colors;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.testing.Ignore;
import org.openqa.selenium.testing.JUnit4TestBase;
import org.openqa.selenium.testing.JavascriptEnabled;
import org.openqa.selenium.testing.NeedsLocalEnvironment;
import org.openqa.selenium.testing.NotYetImplemented;
import org.openqa.selenium.testing.TestUtilities;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import java.awt.*;
import java.util.Map;

/**
Expand Down Expand Up @@ -451,55 +445,6 @@ public void testHoverPersists() throws Exception {
assertEquals("Item 1", item.getText());
}

@JavascriptEnabled
@Ignore(
value = {FIREFOX, CHROME, SAFARI, PHANTOMJS, MARIONETTE},
reason = "This is an IE only tests")
@NotYetImplemented(HTMLUNIT)
@NoDriverAfterTest
@NeedsLocalEnvironment
@Test
public void testPersistentHoverCanBeTurnedOff() throws Exception {
assumeTrue(TestUtilities.isInternetExplorer(driver));
// Destroy the previous driver to make sure the hovering thread is
// stopped.
driver.quit();

DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(ENABLE_PERSISTENT_HOVERING, false);
WebDriverBuilder builder = new WebDriverBuilder().setDesiredCapabilities(caps);
driver = builder.get();

try {
driver.get(pages.javascriptPage);
// Move to a different element to make sure the mouse is not over the
// element with id 'item1' (from a previous test).
new Actions(driver).moveToElement(driver.findElement(By.id("keyUp"))).build().perform();
WebElement element = driver.findElement(By.id("menu1"));

final WebElement item = driver.findElement(By.id("item1"));
assertEquals("", item.getText());

((JavascriptExecutor) driver).executeScript("arguments[0].style.background = 'green'", element);
new Actions(driver).moveToElement(element).build().perform();

// Move the mouse somewhere - to make sure that the thread firing the events making
// hover persistent is not active.
Robot robot = new Robot();
robot.mouseMove(50, 50);

// Intentionally wait to make sure hover DOES NOT persist.
Thread.sleep(1000);

wait.until(elementTextToEqual(item, ""));

assertEquals("", item.getText());

} finally {
driver.quit();
}
}

@JavascriptEnabled
@Ignore(value = {SAFARI, MARIONETTE},
reason = "Advanced mouse actions only implemented in rendered browsers",
Expand Down

0 comments on commit 517c588

Please sign in to comment.