"Fossies" - the Fresh Open Source Software Archive 
Member "selenium-selenium-4.8.1/py/test/selenium/webdriver/common/rendered_webelement_tests.py" (17 Feb 2023, 2497 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the last
Fossies "Diffs" side-by-side code changes report for "rendered_webelement_tests.py":
4.5.0_vs_4.6.0.
1 # Licensed to the Software Freedom Conservancy (SFC) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The SFC licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
16 # under the License.
17
18 import pytest
19
20 from selenium.common.exceptions import WebDriverException
21 from selenium.webdriver.common.by import By
22 from selenium.webdriver.support.color import Color
23
24
25 def test_should_pick_up_style_of_an_element(driver, pages):
26 pages.load("javascriptPage.html")
27
28 element = driver.find_element(by=By.ID, value="green-parent")
29 backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
30 assert Color.from_string("rgba(0, 128, 0, 1)") == backgroundColour
31
32 element = driver.find_element(by=By.ID, value="red-item")
33 backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
34 assert Color.from_string("rgba(255, 0, 0, 1)") == backgroundColour
35
36
37 def test_should_allow_inherited_styles_to_be_used(driver, pages):
38 pages.load("javascriptPage.html")
39 element = driver.find_element(by=By.ID, value="green-item")
40 backgroundColour = Color.from_string(element.value_of_css_property("background-color"))
41 assert backgroundColour == Color.from_string("transparent")
42
43
44 def test_should_correctly_identify_that_an_element_has_width(driver, pages):
45 pages.load("xhtmlTest.html")
46
47 shrinko = driver.find_element(by=By.ID, value="linkId")
48 size = shrinko.size
49 assert size["width"] > 0
50 assert size["height"] > 0
51
52
53 @pytest.mark.xfail_safari(reason="Get Element Rect command not implemented", raises=WebDriverException)
54 def test_should_be_able_to_determine_the_rect_of_an_element(driver, pages):
55 pages.load("xhtmlTest.html")
56
57 element = driver.find_element(By.ID, "username")
58 rect = element.rect
59
60 assert rect["x"] > 0
61 assert rect["y"] > 0
62 assert rect["width"] > 0
63 assert rect["height"] > 0