473,890 Members | 5,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selenium Python Script Issue

1 New Member
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__.SignU pTask)
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.o pen("/")
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 3173
2,851 Recognized Expert Moderator Specialist
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

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.
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 notice that the script died when I logged off. How do I make sure it stays running? thanks,
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 example?? thanks
by: tatamata | last post by:
Hello. How can I run some Python script within C# program? Thanks, Zlatko
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 os.popen('foo.sh') which starts a program/process say 'bar' At some point later, I want to kill 'bar'. Currently, I start off the process and then when the python script exits, the process 'bar' is
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 should be done, but the end product should be "professional" looking. So, I'm looking for some books and suggestions which will help me write high-quality scripts. I know about object-oriented programming and application configuration and have spent...
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 calling API and user define TCL functions from python script. I am looking for the way to include user define TCL lib to python script and call those user define functions from python script. thanks & regards
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 python script seems to be designed for 'non database' sites, not a site which is using .asp, and has dynamic pages. We are an ecommerce site. What are other ecommerce sites using to create an xml file? Are they using the python script?
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 execute them from php using exec. My php code looks something like: exec("python /usr/local/bin/webkit2png2.py -m http://www.google.com -D ~/Desktop/snap");
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 > /tmp/outfile.log 2>&1 & Or, I can put that command in a shell script and run it by typing: ./script.sh Both work great. However I don't know how to put either the command or the shell script in a python.py script and get it to run from there. Let me...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.