Skip to content

Commit

Permalink
Removed the get_computed_property() method. Instead one may use Sel…
Browse files Browse the repository at this point in the history
…enium's built-in `value_of_css_property()` method.
  • Loading branch information
jphalip committed Apr 6, 2014
1 parent e4b0faf commit 3524910
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 47 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Change log
`NeedleTestCase.save_baseline` options. Note that those new options will
systematically cause the baseline image files to be saved on disk,
overwriting potentially existing baseline files.
- Removed the `NeedleWebElement.get_computed_property()` method. Instead, you
may use Selenium's built-in `value_of_css_property()` method.

0.1.0 (2014-02-20)
------------------
Expand Down
16 changes: 0 additions & 16 deletions docs/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,6 @@ If a regression in your CSS causes them to become significantly different, the
test will fail.


Advanced example
----------------

Needle adds :doc:`a few useful methods <api/driver>` to
Selenium's WebElement object. For example, we can check computed CSS values::

from needle.cases import NeedleTestCase

class GoogleTest(NeedleTestCase):
def test_footer(self):
self.driver.get('http://www.google.com')
e = self.driver.find_element_by_id('fctr')
self.assertScreenshot(e, 'google-footer')
self.assertEqual(e.get_computed_property('font-size'), '13px')


API
---

Expand Down
9 changes: 0 additions & 9 deletions needle/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ def get_screenshot(self):
d['top'] + d['height'],
))

def get_computed_property(self, prop):
"""
Returns the computed value of a CSS property.
"""
self._parent.load_jquery()
return self._parent.execute_script("""
return $(arguments[0]).css(arguments[1]);
""", self, prop)


class NeedleWebDriverMixin(object):
"""
Expand Down
23 changes: 1 addition & 22 deletions tests/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_load_html_works_with_large_pages(self):
self.assertEqual(
self.driver.execute_script(
'return document.getElementsByTagName("div").length'
),
),
501
)
e = self.driver.find_element_by_id('test')
Expand Down Expand Up @@ -68,24 +68,3 @@ def test_get_screenshot(self):
self.assertEqual(im.size, (150, 200))
for pixel in im.getdata():
self.assertEqual(pixel, (255, 0, 0))

def test_get_computed_property(self):
self.driver.load_html("""
<style type="text/css">
#outer {
font-size: 10px;
}
#inner {
font-size: 2em;
float: left;
}
</style>
<div id="outer">
<div id="inner">Hello!</div>
</div>
""")
e = self.driver.find_element_by_id('inner')
self.assertEqual(e.get_computed_property('font-size'), '20px')
self.assertEqual(e.get_computed_property('float'), 'left')


0 comments on commit 3524910

Please sign in to comment.