org.openqa.selenium.support.Color Java Examples

The following examples show how to use org.openqa.selenium.support.Color. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MarkerTest.java    From webtester2-core with Apache License 2.0 6 votes vote down vote up
@Test
public void styleIsChangedIfMarkingsAreActivated() {

    doReturn(Color.fromString("#cccccc")).when(configuration).getMarkingsColorUsedBackground();
    doReturn(Color.fromString("#dddddd")).when(configuration).getMarkingsColorUsedOutline();
    doReturn(true).when(configuration).isMarkingsEnabled();

    cut.markAsUsed(fragment);

    verify(styleChanger).changeStyleInformation(same(fragment), cssCaptor.capture());
    Map<String, String> properties = cssCaptor.getValue();

    assertThat(properties).containsEntry(CssProperties.OUTLINE_STYLE, "solid");
    assertThat(properties).containsEntry(CssProperties.OUTLINE_WIDTH, "2px");
    assertThat(properties).containsEntry(CssProperties.OUTLINE_COLOR, "#dddddd");
    assertThat(properties).containsEntry(CssProperties.BACKGROUND_COLOR, "#cccccc");

}
 
Example #2
Source File: MarkerTest.java    From webtester2-core with Apache License 2.0 6 votes vote down vote up
@Test
public void styleIsChangedIfMarkingsAreActivated() {

    doReturn(Color.fromString("#aaaaaa")).when(configuration).getMarkingsColorReadBackground();
    doReturn(Color.fromString("#bbbbbb")).when(configuration).getMarkingsColorReadOutline();
    doReturn(true).when(configuration).isMarkingsEnabled();

    cut.markAsRead(fragment);

    verify(styleChanger).changeStyleInformation(same(fragment), cssCaptor.capture());
    Map<String, String> properties = cssCaptor.getValue();

    assertThat(properties).containsEntry(CssProperties.OUTLINE_STYLE, "solid");
    assertThat(properties).containsEntry(CssProperties.OUTLINE_WIDTH, "2px");
    assertThat(properties).containsEntry(CssProperties.OUTLINE_COLOR, "#bbbbbb");
    assertThat(properties).containsEntry(CssProperties.BACKGROUND_COLOR, "#aaaaaa");

}
 
Example #3
Source File: QAFWebElementExpectedConditions.java    From qaf with MIT License 5 votes vote down vote up
public static ExpectedCondition<QAFExtendedWebElement, Boolean> elementCssColorPropertyValueEq(final String propertyName,
		final Object val) {
	return new ExpectedCondition<QAFExtendedWebElement, Boolean>() {
		@Override
		public Boolean apply(QAFExtendedWebElement element) {
			return Color.fromString(element.getCssValue(propertyName)).asRgba().equals(Color.fromString(String.valueOf(val)).asRgba());
		}
	};
}
 
Example #4
Source File: CssValueTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetCssValueShouldReturnStandardizedColour() {
  driver.get(pages.colorPage);

  WebElement element = driver.findElement(By.id("namedColor"));
  Color backgroundColour = Color.fromString(element.getCssValue("background-color"));
  assertThat(backgroundColour).isEqualTo(new Color(0, 128, 0, 1));

  element = driver.findElement(By.id("rgb"));
  backgroundColour = Color.fromString(element.getCssValue("background-color"));
  assertThat(backgroundColour).isEqualTo(new Color(0, 128, 0, 1));
}
 
Example #5
Source File: CssValueTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void testShouldPickUpStyleOfAnElement() {
  driver.get(pages.javascriptPage);

  WebElement element = driver.findElement(By.id("green-parent"));
  Color backgroundColour = Color.fromString(element.getCssValue("background-color"));

  assertThat(backgroundColour).isEqualTo(new Color(0, 128, 0, 1));

  element = driver.findElement(By.id("red-item"));
  backgroundColour = Color.fromString(element.getCssValue("background-color"));

  assertThat(backgroundColour).isEqualTo(new Color(255, 0, 0, 1));
}
 
Example #6
Source File: BasicMouseInterfaceTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
@Ignore(value = MARIONETTE, issue = "https://github.com/mozilla/geckodriver/issues/789")
@NotYetImplemented(HTMLUNIT)
@NotYetImplemented(SAFARI)
@NotYetImplemented(EDGE)
public void testCanMoveOverAndOutOfAnElement() {
  driver.get(pages.mouseOverPage);

  WebElement greenbox = driver.findElement(By.id("greenbox"));
  WebElement redbox = driver.findElement(By.id("redbox"));
  Dimension greenSize = greenbox.getSize();
  Dimension redSize = redbox.getSize();

  new Actions(driver).moveToElement(greenbox, 1 - greenSize.getWidth() / 2, 1 - greenSize.getHeight() / 2).perform();

  assertThat(Color.fromString(redbox.getCssValue("background-color")))
      .isEqualTo(GREEN.getColorValue());

  new Actions(driver).moveToElement(redbox).perform();
  assertThat(Color.fromString(redbox.getCssValue("background-color")))
      .isEqualTo(RED.getColorValue());

  // IE8 (and *only* IE8) requires a move of 2 pixels. All other browsers
  // would be happy with 1.
  new Actions(driver).moveToElement(redbox, redSize.getWidth() / 2 + 2, redSize.getHeight() / 2 + 2)
      .perform();

  wait.until(attributeToBe(redbox, "background-color", Colors.GREEN.getColorValue().asRgba()));
}
 
Example #7
Source File: Marker.java    From webtester-core with Apache License 2.0 5 votes vote down vote up
private static void markElement(PageObject pageObject, Color backgroundColor, Color outlineColor) {

        Map<CSSProperty, String> cssStyleAttributes = new HashMap<CSSProperty, String>();
        cssStyleAttributes.put(CSSProperties.OUTLINE_STYLE, "solid");
        cssStyleAttributes.put(CSSProperties.OUTLINE_WIDTH, "2px");
        cssStyleAttributes.put(CSSProperties.OUTLINE_COLOR, outlineColor.asHex());
        cssStyleAttributes.put(CSSProperties.BACKGROUND_COLOR, backgroundColor.asHex());

        styleChanger.changeStyleInformation(pageObject, cssStyleAttributes);

    }
 
Example #8
Source File: Marker.java    From webtester-core with Apache License 2.0 5 votes vote down vote up
/**
 * Marks the given {@link PageObject page object} as 'read' using the
 * configured colors from the page object's browser's {@link Configuration
 * configuration}.
 *
 * @param pageObject the page object to mark.
 * @since 1.2
 */
public static void markAsRead(PageObject pageObject) {
    Configuration configuration = pageObject.getBrowser().getConfiguration();
    if (configuration.markingsAreActivated()) {
        Color backgroundColor = configuration.getMarkingsColorReadBackground();
        Color outlineColor = configuration.getMarkingsColorReadOutline();
        markElement(pageObject, backgroundColor, outlineColor);
    }
}
 
Example #9
Source File: Marker.java    From webtester-core with Apache License 2.0 5 votes vote down vote up
/**
 * Marks the given {@link PageObject page object} as 'used' using the
 * configured colors from the page object's browser's {@link Configuration
 * configuration}.
 *
 * @param pageObject the page object to mark.
 * @since 0.9.6
 */
public static void markAsUsed(PageObject pageObject) {
    Configuration configuration = pageObject.getBrowser().getConfiguration();
    if (configuration.markingsAreActivated()) {
        Color backgroundColor = configuration.getMarkingsColorUsedBackground();
        Color outlineColor = configuration.getMarkingsColorUsedOutline();
        markElement(pageObject, backgroundColor, outlineColor);
    }
}
 
Example #10
Source File: QAFWebElementExpectedConditions.java    From qaf with MIT License 5 votes vote down vote up
public static ExpectedCondition<QAFExtendedWebElement, Boolean> elementCssColorPropertyValueNotEq(
		final String propertyName, final Object val) {
	return new ExpectedCondition<QAFExtendedWebElement, Boolean>() {
		@Override
		public Boolean apply(QAFExtendedWebElement element) {
			return !Color.fromString(element.getCssValue(propertyName)).asRgba().equals(Color.fromString(String.valueOf(val)).asRgba());
		}
	};
}
 
Example #11
Source File: BaseConfigurationTest.java    From webtester2-core with Apache License 2.0 5 votes vote down vote up
@Test
void markingsColorReadOutlineCanBeChanged() {
    Color color = Colors.AZURE.getColorValue();
    Configuration configuration = cut.setMarkingsColorReadOutline(color);
    assertThat(cut.getMarkingsColorReadOutline()).isEqualTo(color);
    assertThat(configuration).isSameAs(cut);
}
 
Example #12
Source File: BaseConfigurationTest.java    From webtester2-core with Apache License 2.0 5 votes vote down vote up
@Test
void markingsColorReadBackgroundCanBeChanged() {
    Color color = Colors.ANTIQUEWHITE.getColorValue();
    Configuration configuration = cut.setMarkingsColorReadBackground(color);
    assertThat(cut.getMarkingsColorReadBackground()).isEqualTo(color);
    assertThat(configuration).isSameAs(cut);
}
 
Example #13
Source File: BaseConfigurationTest.java    From webtester2-core with Apache License 2.0 5 votes vote down vote up
@Test
void markingsColorUsedOutlineCanBeChanged() {
    Color color = Colors.ALICEBLUE.getColorValue();
    Configuration configuration = cut.setMarkingsColorUsedOutline(color);
    assertThat(cut.getMarkingsColorUsedOutline()).isEqualTo(color);
    assertThat(configuration).isSameAs(cut);
}
 
Example #14
Source File: BaseConfigurationTest.java    From webtester2-core with Apache License 2.0 5 votes vote down vote up
@Test
void markingsColorUsedBackgroundCanBeChanged() {
    Color color = Colors.BLUEVIOLET.getColorValue();
    Configuration configuration = cut.setMarkingsColorUsedBackground(color);
    assertThat(cut.getMarkingsColorUsedBackground()).isEqualTo(color);
    assertThat(configuration).isSameAs(cut);
}
 
Example #15
Source File: Marker.java    From webtester2-core with Apache License 2.0 5 votes vote down vote up
private void markElement(PageFragment fragment, Color backgroundColor, Color outlineColor) {

        Map<String, String> cssStyleAttributes = new HashMap<>();
        cssStyleAttributes.put(CssProperties.OUTLINE_STYLE, "solid");
        cssStyleAttributes.put(CssProperties.OUTLINE_WIDTH, "2px");
        cssStyleAttributes.put(CssProperties.OUTLINE_COLOR, outlineColor.asHex());
        cssStyleAttributes.put(CssProperties.BACKGROUND_COLOR, backgroundColor.asHex());

        styleChanger.changeStyleInformation(fragment, cssStyleAttributes);

    }
 
Example #16
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorUsedBackground() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_USED_BACKGROUND), "#ffd2a5"));
}
 
Example #17
Source File: BaseConfiguration.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorReadBackground() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_COLOR_READ_BACKGROUND), "#90ee90"));
}
 
Example #18
Source File: BaseConfiguration.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Override
public BaseConfiguration setMarkingsColorReadBackground(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_COLOR_READ_BACKGROUND), color.toString());
}
 
Example #19
Source File: BaseConfiguration.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorReadOutline() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_COLOR_READ_OUTLINE), "#008000"));
}
 
Example #20
Source File: BaseConfiguration.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Override
public BaseConfiguration setMarkingsColorReadOutline(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_COLOR_READ_OUTLINE), color.toString());
}
 
Example #21
Source File: BasicKeyboardInterfaceTest.java    From selenium with Apache License 2.0 4 votes vote down vote up
private void assertBackgroundColor(WebElement el, Colors expected) {
  Color actual = Color.fromString(el.getCssValue("background-color"));
  assertThat(actual).isEqualTo(expected.getColorValue());
}
 
Example #22
Source File: BaseConfiguration.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Override
public BaseConfiguration setMarkingsColorUsedOutline(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_COLOR_USED_OUTLINE), color.toString());
}
 
Example #23
Source File: BaseConfiguration.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorUsedOutline() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_COLOR_USED_OUTLINE), "#916f22"));
}
 
Example #24
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public Configuration setMarkingsColorReadOutline(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_READ_OUTLINE), color.asHex());
}
 
Example #25
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public BaseConfiguration setMarkingsColorUsedBackground(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_USED_BACKGROUND), color.asHex());
}
 
Example #26
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorUsedOutline() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_USED_OUTLINE), "#916f22"));
}
 
Example #27
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public BaseConfiguration setMarkingsColorUsedOutline(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_USED_OUTLINE), color.asHex());
}
 
Example #28
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorReadBackground() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_READ_BACKGROUND), "#90ee90"));
}
 
Example #29
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public Configuration setMarkingsColorReadBackground(Color color) {
    return setProperty(key(NamedProperties.MARKINGS_READ_BACKGROUND), color.asHex());
}
 
Example #30
Source File: BaseConfiguration.java    From webtester2-core with Apache License 2.0 4 votes vote down vote up
@Override
public Color getMarkingsColorReadOutline() {
    return Color.fromString(getStringProperty(key(NamedProperties.MARKINGS_READ_OUTLINE), "#008000"));
}