On Feb 2, 7:03 am, Duncan Booth <duncan.bo...@invalid.invalid> wrote: > Stefan Behnel <stefan...@behnel.de> wrote: > > You are using Selenium RC here. I have no idea if there is a Python > > API to it or what that API looks like. The rest is just trivial code > > that you can map 1:1 to Python: > > > def count_css_matches(css_locator): > > java_script_code = ''' > > var cssMatches = eval_css("%s", window.document); > > cssMatches.length;''' % css_locator > > return int(selenium.getEval(java_script_code)) > > > Although I'd simplify the JavaScript code somewhat to make it a plain > > expression. > > You also need somewhere: > > from selenium import selenium > > and in Python the method that is needed is selenium.get_eval(...) > > -- > Duncan Boothhttp://kupuguy.blogspot.com
On Feb 2, 7:03 am, Duncan Booth <duncan.bo...@invalid.invalid> wrote: > Stefan Behnel <stefan...@behnel.de> wrote: > > You are using Selenium RC here. I have no idea if there is a Python > > API to it or what that API looks like. The rest is just trivial code > > that you can map 1:1 to Python: > > > def count_css_matches(css_locator): > > java_script_code = ''' > > var cssMatches = eval_css("%s", window.document); > > cssMatches.length;''' % css_locator > > return int(selenium.getEval(java_script_code)) > > > Although I'd simplify the JavaScript code somewhat to make it a plain > > expression. > > You also need somewhere: > > from selenium import selenium > > and in Python the method that is needed is selenium.get_eval(...) > > -- > Duncan Boothhttp://kupuguy.blogspot.com Hi All, Thanks a lot for the help. I feel like I've made some progress, yet I am still stuck with the following error when I try to print self.count_css_matches('css=[id="listGuests"]') I've also included the Selenium code below. Any further help would be appreciated. Traceback (most recent call last): File "D:\Temp\1TestingApps\Selenium\Scripts\SevPractice.py", line 27, in test_untitled print self.count_css_matches('css=[id="listGuests"]') File "D:\Temp\1TestingApps\Selenium\Scripts\SevPractice.py", line 17, in count_css_matches return int(selenium.get_eval(self, java_script_code)) TypeError: unbound method get_eval() must be called with selenium instance as first argument (got Untitled instance instead) ---------------------------------------------------------------------- from selenium import selenium import unittest, time from datetime import datetime class Untitled(unittest.TestCase): def count_css_matches(self, css_locator): java_script_code = ''' var cssMatches = eval_css("%s", window.document); cssMatches.length;''' % css_locator return int(selenium.get_eval(self, java_script_code)) #return int(selenium.getEval(java_script_code)) def setUp(self): self.verificationErrors = [] self.selenium = selenium("localhost", 4445, "*chrome", "http:// www.guestlistnation.com/") self.selenium.start() def test_untitled(self): sel = self.selenium sel.window_maximize() sel.open("/Events.aspx?Location=SAN FRANCISCO") sel.click("css=[id='EventDates_ctl00_NestedEvents_ctl01_btnDetails']") sel.wait_for_page_to_load("30000") print self.count_css_matches('css=[id="listGuests"]') if __name__ == "__main__": unittest.main() -- http://mail.python.org/mailman/listinfo/python-list