Path: blob/trunk/py/test/selenium/webdriver/common/rendered_webelement_tests.py
1865 views
# Licensed to the Software Freedom Conservancy (SFC) under one1# or more contributor license agreements. See the NOTICE file2# distributed with this work for additional information3# regarding copyright ownership. The SFC licenses this file4# to you under the Apache License, Version 2.0 (the5# "License"); you may not use this file except in compliance6# with the License. You may obtain a copy of the License at7#8# http://www.apache.org/licenses/LICENSE-2.09#10# Unless required by applicable law or agreed to in writing,11# software distributed under the License is distributed on an12# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY13# KIND, either express or implied. See the License for the14# specific language governing permissions and limitations15# under the License.1617import pytest1819from selenium.common.exceptions import WebDriverException20from selenium.webdriver.common.by import By21from selenium.webdriver.support.color import Color222324def test_should_pick_up_style_of_an_element(driver, pages):25pages.load("javascriptPage.html")2627element = driver.find_element(by=By.ID, value="green-parent")28backgroundColour = Color.from_string(element.value_of_css_property("background-color"))29assert Color.from_string("rgba(0, 128, 0, 1)") == backgroundColour3031element = driver.find_element(by=By.ID, value="red-item")32backgroundColour = Color.from_string(element.value_of_css_property("background-color"))33assert Color.from_string("rgba(255, 0, 0, 1)") == backgroundColour343536def test_should_allow_inherited_styles_to_be_used(driver, pages):37pages.load("javascriptPage.html")38element = driver.find_element(by=By.ID, value="green-item")39backgroundColour = Color.from_string(element.value_of_css_property("background-color"))40assert backgroundColour == Color.from_string("transparent")414243def test_should_correctly_identify_that_an_element_has_width(driver, pages):44pages.load("xhtmlTest.html")4546shrinko = driver.find_element(by=By.ID, value="linkId")47size = shrinko.size48assert size["width"] > 049assert size["height"] > 0505152@pytest.mark.xfail_safari(reason="Get Element Rect command not implemented", raises=WebDriverException)53def test_should_be_able_to_determine_the_rect_of_an_element(driver, pages):54pages.load("xhtmlTest.html")5556element = driver.find_element(By.ID, "username")57rect = element.rect5859assert rect["x"] > 060assert rect["y"] > 061assert rect["width"] > 062assert rect["height"] > 0636465