473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

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
  3.  
  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"""
  8.  
  9.     def setUp(self):
  10.         self.selenium = selenium("localhost", 4444, "*firefox",
  11.                 "http://www.google.com/")
  12.         self.selenium.start()
  13.  
  14.  
  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
  25.  
  26.     def tearDown(self):
  27.         self.selenium.stop()
  28.  
  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
self.selenium.open("/")
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!!

.erik
Jan 11 '11 #1
1 3156
bvdet
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

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

Similar topics

7
by: Andrew Chalk | last post by:
Is this possible? In my CGI app. I display a web page with a link (anchor). When the link is clicked I want to exectute a python script rather than go to an HTML page. Many thanks.
8
by: Harlin Seritt | last post by:
I have a remote linux server where I can only access it via ssh. I have a script that I need to have run all the time. I run like so: python script.py & It runs fine. When I log off ssh I...
2
by: Sibou51 | last post by:
Hello everybody, do you know if it's possible to call a python script in html page?? I want call my script pyhton and I have a html with javascript but I don't know how, do you have an...
6
by: tatamata | last post by:
Hello. How can I run some Python script within C# program? Thanks, Zlatko
1
by: dfaber | last post by:
Aloha! I want to terminate a process/program from within a python script. For example, if I have a program say foo.sh that starts running, then I can run it from within a python script using...
6
by: metaperl | last post by:
Hello, I am responsible for converting 30 loosey-goosey Perl scripts into 30 well-documented easy to understand and use Python scripts. No one has said anything in particular about how this...
1
by: comp.lang.python | last post by:
Hi, I am using some TCL driver APIs and user define TCL function to control a traffic generator. The APIs are the traffic generator's specific and in built to the driver library. The issue is...
1
by: michael.buonomo | last post by:
We have been using the Google recommended python script for about a year. We recently realized that the script was not crawling our sites url's, but just our folders which reside on the server. The...
0
by: browntown | last post by:
Hi...i'm relatively new to python...i'm trying to use webkit2png to take some screenshots. Everything works fine when I run the script from the command line...things do not work when i try to...
2
by: gintrado | last post by:
I am very new to Python I'm trying to run a python script from within another python script. I can run the script from a unix command line by typing: nohup python script.py password >...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.