468,253 Members | 1,314 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,253 developers. It's quick & easy.

Selenium Python Script Issue

Hey I am trying to get the hang of both Python and Selenium RC at the same time and having a bit of difficulty and was wondering if anyone here could assist me validating my Python Script. I've gotten rid of most of the initial errors besides one.

Here is my Python Script

Expand|Select|Wrap|Line Numbers
  1. from selenium import selenium
  2. import unittest
  4. class SignUpTask(unittest.TestCase):
  5.     """ The following needs to have the issues corrected to make 
  6.         it run. When the run is completed the answer for question 
  7.         2 will be shown"""
  9.     def setUp(self):
  10.         self.selenium = selenium("localhost", 4444, "*firefox",
  11.                 "http://www.google.com/")
  12.         self.selenium.start()
  15.     def test_that_will_print_out_a_url_as_answer_for_task(sel):
  16.         self.selenium.open("/")
  17.         self.selenium.click("link=Web QA")
  18.         self.selenium.wait_for_page_to_load("30000")
  19.         self.selenium.click("link=Get Involved")
  20.         self.selenium.wait_for_page_to_load("30000")
  21.         url = self.selenium.get_attribute("//ol/li[5]/a@href")
  22.         print """The Url below needs to be entered as the answer 
  23.                  for Question 2) in the signup task"""
  24.         print "URL is: %s" % url
  26.     def tearDown(self):
  27.         self.selenium.stop()
  29. if __name__ == "__main__":
  30.     unittest.main()
I run the Python script and then get the following error:
================================================== ====================
ERROR: test_that_will_print_out_a_url_as_answer_for_task (__main__.SignUpTask)
Traceback (most recent call last):
File "/Users/eanderson/Desktop/TestFiles/Selenium1.py", line 16, in test_that_will_print_out_a_url_as_answer_for_task
NameError: global name 'self' is not defined

Ran 1 test in 24.577s

Could anyone help me with this "NameError: global name 'self' is not defined" error so my script can parse?

Thank You!!

Jan 11 '11 #1
1 2960
2,851 Expert Mod 2GB
def test_that_will_print_out_a_url_as_answer_for_task( sel) should be def test_that_will_print_out_a_url_as_answer_for_task( self)
Jan 11 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

7 posts views Thread by Andrew Chalk | last post: by
8 posts views Thread by Harlin Seritt | last post: by
2 posts views Thread by Sibou51 | last post: by
6 posts views Thread by tatamata | last post: by
6 posts views Thread by metaperl | last post: by
1 post views Thread by comp.lang.python | last post: by
1 post views Thread by michael.buonomo | last post: by
reply views Thread by browntown | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.