Skip to content

Commit e3744a1

Browse files
committed
add wk_check/_unckeck methods
1 parent 1bced18 commit e3744a1

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CHANGELOG
33
1.10 (unreleased)
44
-----------------
55

6-
- Nothing changed yet.
6+
- add wk_check/_unckeck methods
77

88

99
1.9 (2011-05-29)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import os
1919
from distutils.cmd import Command
2020

21-
version = '1.10dev'
21+
version = '1.10'
2222
url = "https://github.com/kiorky/spynner"
2323

2424
class gen_doc(Command):

src/spynner/browser.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,26 @@ def wk_fill(self, selector, value):
957957
element = self.webframe.findFirstElement(selector)
958958
element.evaluateJavaScript("this.value = '%s'" % value)
959959

960+
def wk_check_elem(self, element):
961+
"""check an input checkbox using a webkit element."""
962+
jscode = "this.checked=true;"
963+
element.evaluateJavaScript(jscode)
964+
965+
def wk_uncheck_elem(self, element):
966+
"""uncheck input checkbox using a Webkit element"""
967+
jscode = "this.checked=false;"
968+
element.evaluateJavaScript(jscode)
969+
970+
def wk_check(self, selector):
971+
"""check an input checkbox using a css selector."""
972+
element = self.webframe.findFirstElement(selector)
973+
return self.wk_check_elem(element)
974+
975+
def wk_uncheck(self, selector):
976+
"""uncheck input checkbox using a css selector"""
977+
element = self.webframe.findFirstElement(selector)
978+
return self.wk_uncheck_elem(element)
979+
960980
def check(self, selector):
961981
"""Check an input checkbox using a jQuery selector."""
962982
jscode = "%s('%s').attr('checked', true)" % (self.jslib, selector)
@@ -978,6 +998,31 @@ def select(self, selector):
978998
jscode = "%s('%s').attr('selected', 'selected')" % (self.jslib, selector)
979999
self._runjs_on_jquery("select", jscode)
9801000

1001+
# TODO: finish to implement
1002+
#def wk_select_elem(self, element, values):
1003+
# """Choose a option in a select using WebKit API.
1004+
# @param element: webkit WebElemement
1005+
# """
1006+
# for value in values:
1007+
# element.evaluateJavaScript(
1008+
# "for(var i=0; i < document.formname.dropdownboxname.length; i++) {"
1009+
# 'if (document.formname.dropdownboxname[i].value == "value") {'
1010+
# 'document.formname.dropdownboxname[i].selected = true;'
1011+
# '}'
1012+
# '}'
1013+
# )
1014+
# jscode = "%s('%s').attr('selected', 'selected')" % (self.jslib, selector)
1015+
# self._runjs_on_jquery("select", jscode)
1016+
1017+
#def wk_select(self, selector, values):
1018+
# """Choose a option in a select using WebKit API.
1019+
# @param selector: css selector to get the select item.
1020+
# @param value: list of values to set pass a [value] for a single value.
1021+
# """
1022+
# element = self.webframe.findFirstElement(selector)
1023+
# return self.wk_select_elem(element, values)
1024+
1025+
9811026
submit = click_link
9821027

9831028
#}

0 commit comments

Comments
 (0)