Source

PunkyBrowster / tests / test_extract_values.py

Diff from to

tests/test_extract_values.py

 from punky.browster import PunkyError
 
 
-def test_value_checked_selected():
+def test_value_checked_selected_by_css():
     """Do the value(), checked() and selected() methods return the expected
     values?
     """
     eq_(browser.selected('form option:first-child'), False)
     eq_(browser.selected('form option:nth-child(3)'), True)
 
+def test_value_checked_selected_by_element():
+    """Do the value(), checked() and selected() methods return the expected
+    values when called directly on elements?
+    """
+    browser.load('tests/pages/test_extract_values.html')
+
+    elem1 = browser.first('form input[type=text]')
+    eq_(browser.value(elem1), 'antelope')
+
+    elem2 = browser.first('form textarea')
+    eq_(browser.value(elem2), 'banana')
+
+    elem3 = browser.first('form input[type=checkbox]')
+    eq_(browser.checked(elem3), True)
+
+    elem4 = browser.first('form input[type=radio]')
+    eq_(browser.checked(elem4), False)
+
+    elem5 = browser.first('form option:first-child')
+    eq_(browser.selected(elem5), False)
+
+    elem6 = browser.first('form option:nth-child(3)')
+    eq_(browser.selected(elem6), True)
+
 
 def test_value_checked_selected_with_exceptions():
     """Do the value(), checked() and selected() methods raise the expected
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.