Hey There. I am trying to get the hang of both Python and Selenium RC and am having some difficulty getting the following sample Selenium Python Script to parse. I have resolved all of the following code's errors besides one:
from selenium import selenium
import unittest
class SignUpTask(unittest.TestCase):
""" The following needs to have the issues corrected to make
it run. When the run is completed the answer for question
2 will be shown"""
def setUp(self):
self.selenium = selenium("localhost", 4444, "*firefox",
"http://www.google.com/")
self.selenium.start()
def test_that_will_print_out_a_url_as_answer_for_task(sel):
self.selenium.open("/")
self.selenium.click("link=Web QA")
self.selenium.wait_for_page_to_load("30000")
self.selenium.click("link=Get Involved")
self.selenium.wait_for_page_to_load("30000")
url = self.selenium.get_attribute("//ol/li[5]/a@href")
print """The Url below needs to be entered as the answer
for Question 2) in the signup task"""
print "URL is: %s" % url
def tearDown(self):
self.selenium.stop()
if __name__ == "__main__":
unittest.main()
After running the above script via Selenium RC, I 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 self.selenium.open("/") NameError: global name 'self' is not defined
Ran 1 test in 24.577s
failed (errors=1)
Does anyone out there understand why I am getting the "NameError: global name 'self' is not defined" error on line 16 and could help me alleviate this error so my script can parse without error.
Thanks!
.erik