Skip to content

Commit

Permalink
[py] Use Color in rendered_webelement_tests (#5360)
Browse files Browse the repository at this point in the history
WebDriver spec decided that CSS values returned should be whatever the
browser returns, without imposing any format for colors. By using Color
class in the tests we can compare colors even if different formats (RGB
vs RGBA) are used.
  • Loading branch information
carlosgcampos authored and lmtierney committed Jan 18, 2018
1 parent f907cd5 commit 01cc729
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions py/test/selenium/webdriver/common/rendered_webelement_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,26 @@

from selenium.common.exceptions import WebDriverException
from selenium.webdriver.common.by import By
from selenium.webdriver.support.color import Color


@pytest.mark.xfail_marionette(
reason='https://github.com/w3c/webdriver/issues/417')
def testShouldPickUpStyleOfAnElement(driver, pages):
pages.load("javascriptPage.html")

element = driver.find_element(by=By.ID, value="green-parent")
backgroundColour = element.value_of_css_property("background-color")
assert "rgba(0, 128, 0, 1)" == backgroundColour
backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
assert Color.from_string("rgba(0, 128, 0, 1)") == backgroundColour

element = driver.find_element(by=By.ID, value="red-item")
backgroundColour = element.value_of_css_property("background-color")
assert "rgba(255, 0, 0, 1)" == backgroundColour
backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
assert Color.from_string("rgba(255, 0, 0, 1)") == backgroundColour


def testShouldAllowInheritedStylesToBeUsed(driver, pages):
pages.load("javascriptPage.html")
element = driver.find_element(by=By.ID, value="green-item")
backgroundColour = element.value_of_css_property("background-color")
assert backgroundColour in ("rgba(0, 0, 0, 0)", "transparent")
backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
assert backgroundColour == Color.from_string("transparent")


def testShouldCorrectlyIdentifyThatAnElementHasWidth(driver, pages):
Expand Down

0 comments on commit 01cc729

Please sign in to comment.