Adding value_of_css_property method#291
Merged
mshriver merged 1 commit intoRedHatQE:mainfrom Oct 22, 2025
Merged
Conversation
Reviewer's GuideIntroduces a new value_of_css_property method to fetch computed CSS properties from elements, adds corresponding tests, and updates the default viewport size in test fixtures. Sequence diagram for value_of_css_property method executionsequenceDiagram
actor User
participant Browser
participant Element
User->>Browser: value_of_css_property(locator, property)
Browser->>Browser: logger.debug(...)
Browser->>Element: element(locator)
Browser->>Element: evaluate("window.getComputedStyle(element).getPropertyValue(property)")
Element-->>Browser: CSS property value
Browser-->>User: CSS property value
Class diagram for the new value_of_css_property method in BrowserclassDiagram
class Browser {
+set_attribute(attr: str, value: str, *args, **kwargs)
+value_of_css_property(locator: LocatorAlias, property: str, *args, **kwargs) Optional[str]
+size_of(*args, **kwargs) Size
}
Browser : value_of_css_property() uses element()
Browser : value_of_css_property() calls logger.debug()
Browser : value_of_css_property() returns el.evaluate()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/widgetastic/browser.py:807` </location>
<code_context>
+ Returns:
+ Value of css property.
+ """
+ self.logger.debug("Retrieving value of css property: %r ", locator)
+ el = self.element(locator=locator)
+ return el.evaluate(
</code_context>
<issue_to_address>
**suggestion:** The debug log message could include the property name for better traceability.
Adding the property name to the log will clarify which property is being accessed for each locator, improving debugging of style-related issues.
```suggestion
self.logger.debug("Retrieving value of css property '%s' for locator: %r", property, locator)
```
</issue_to_address>
### Comment 2
<location> `testing/test_browser.py:536-541` </location>
<code_context>
assert browser.get_attribute("foo", "#invisible") == "bar"
+def test_value_of_css_property(browser):
+ assert browser.value_of_css_property(locator="#test-image-full", property="margin") == "5px"
+ assert (
</code_context>
<issue_to_address>
**suggestion (testing):** Consider adding tests for edge cases such as non-existent elements and invalid CSS properties.
Please include tests for scenarios where the locator does not match any element and where the CSS property is invalid or unset, to verify correct error handling or return values.
```suggestion
def test_value_of_css_property(browser):
assert browser.value_of_css_property(locator="#test-image-full", property="margin") == "5px"
assert (
browser.value_of_css_property(locator="#test-image-full", property="border-color")
== "rgb(221, 221, 221)"
)
def test_value_of_css_property_nonexistent_element(browser):
# Should raise an exception or return None/empty string if element does not exist
try:
result = browser.value_of_css_property(locator="#does-not-exist", property="margin")
# Accept either None or empty string as valid "not found" result
assert result in (None, "")
except Exception:
# If an exception is expected, pass the test
pass
def test_value_of_css_property_invalid_property(browser):
# Should raise an exception or return None/empty string if property is invalid or unset
result = browser.value_of_css_property(locator="#test-image-full", property="not-a-real-property")
assert result in (None, "")
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #291 +/- ##
=======================================
Coverage 93.49% 93.50%
=======================================
Files 19 19
Lines 2613 2617 +4
=======================================
+ Hits 2443 2447 +4
Misses 170 170
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
67f3ea5 to
9fd3e18
Compare
9fd3e18 to
e5966fa
Compare
mshriver
approved these changes
Oct 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add a new method to retrieve computed CSS property values of elements, validate it with tests, and update test viewport dimensions
New Features:
Enhancements:
Tests: