@@ -957,6 +957,26 @@ def wk_fill(self, selector, value):
957
957
element = self .webframe .findFirstElement (selector )
958
958
element .evaluateJavaScript ("this.value = '%s'" % value )
959
959
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
+
960
980
def check (self , selector ):
961
981
"""Check an input checkbox using a jQuery selector."""
962
982
jscode = "%s('%s').attr('checked', true)" % (self .jslib , selector )
@@ -978,6 +998,31 @@ def select(self, selector):
978
998
jscode = "%s('%s').attr('selected', 'selected')" % (self .jslib , selector )
979
999
self ._runjs_on_jquery ("select" , jscode )
980
1000
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
+
981
1026
submit = click_link
982
1027
983
1028
#}
0 commit comments