예제 #1
0
 public WebElementFacade waitUntilPresent() {
   try {
     waitForCondition().until(elementIsPresent());
   } catch (TimeoutException timeout) {
     throwErrorWithCauseIfPresent(timeout, timeout.getMessage());
   }
   return this;
 }
 @Override
 public WebElementFacade waitUntilPresent() {
   try {
     if (!driverIsDisabled()) {
       waitForCondition().until(elementIsPresent());
     }
   } catch (TimeoutException timeout) {
     throwShouldBePresentErrorWithCauseIfPresent(timeout, timeout.getMessage());
   }
   return this;
 }
  // Given the user is logged in
  // When the user selects the night mode toggle link,
  // Then the page will assume the opposite theme as what they had.
  @Test
  public void testToggleDarkMode() throws InterruptedException {
    login();
    WebElement body = driver.findElement(By.tagName("body"));
    String className = body.getAttribute("class");
    String colorOriginal = body.getCssValue("background-color");
    String expect;
    if (className.equals("dark")) {
      expect = "light";
    } else {
      expect = "dark";
    }
    WebElement toggle = driver.findElement(By.id("nightmodetoggle"));
    toggle.click();
    try {
      wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className(expect)));
    } catch (TimeoutException e) {
      fail(e.getMessage());
    }
    WebElement body2 = driver.findElement(By.tagName("body"));
    String colorToggled = body2.getCssValue("background-color");

    assertNotEquals(colorOriginal, colorToggled);
  }