Exemplo n.º 1
0
  @JavascriptEnabled
  @Ignore(
      value = {HTMLUNIT, IPHONE, SELENESE, OPERA, FIREFOX},
      reason = "This is an IE only tests")
  @NoDriverAfterTest
  @NeedsLocalEnvironment
  @Test
  public void testPersistentHoverCanBeTurnedOff() throws Exception {
    if (!hasInputDevices()) {
      return;
    }

    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);

      waitFor(
          new Callable<Boolean>() {

            public Boolean call() throws Exception {
              return item.getText().equals("");
            }
          });

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

    } finally {
      driver.quit();
    }
  }
Exemplo n.º 2
0
 @Test
 public void shouldBeAbleToEnableProfilerLog() {
   DesiredCapabilities caps = new DesiredCapabilities();
   caps.setCapability(ENABLE_PROFILING_CAPABILITY, true);
   WebDriverBuilder builder = new WebDriverBuilder().setDesiredCapabilities(caps);
   localDriver = builder.get();
   Set<String> logTypes = localDriver.manage().logs().getAvailableLogTypes();
   assertTrue("Profiler log should be enabled", logTypes.contains(LogType.PROFILER));
 }
  @Test
  public void testPriorityForProfilerCapability() {
    // TODO: Resolve why this test doesn't work on the remote server
    assumeTrue(TestUtilities.isLocal());

    WebDriverBuilder builder =
        new WebDriverBuilder()
            .setDesiredCapabilities(getCapabilitiesWithProfilerOn(false))
            .setRequiredCapabilities(getCapabilitiesWithProfilerOn(true));
    localDriver = builder.get();

    assertEquals(
        "Start up should render four profiling entries",
        4,
        getProfilerEntriesOfType(getProfilerEntries(localDriver), EventType.HTTP_COMMAND).size());
  }
  @Test
  @Ignore(
      value = {IE},
      reason = "IE: required capabilities not implemented")
  public void requiredUnhandledAlertCapabilityHasPriorityOverDesired() {
    // TODO: Resolve why this test doesn't work on the remote server
    assumeTrue(TestUtilities.isLocal());

    desiredCaps.setCapability(UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.DISMISS);
    DesiredCapabilities requiredCaps = new DesiredCapabilities();
    requiredCaps.setCapability(UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.ACCEPT);
    WebDriverBuilder builder =
        new WebDriverBuilder()
            .setDesiredCapabilities(desiredCaps)
            .setRequiredCapabilities(requiredCaps);
    driver2 = builder.get();

    runScenarioWithUnhandledAlert("This is a default value");
  }
 private void startLoggingDriver() {
   WebDriverBuilder builder =
       new WebDriverBuilder().setDesiredCapabilities(getCapabilitiesWithProfilerOn(true));
   localDriver = builder.get();
 }