Python Dev Workbook

Python Development Workbook

 

  • Eclipse Juno
  • PyDev AddOn:
  • PyDev for Eclipse, Install, Ack EULA
  • Select Certificate for PyDev..
  • Window > Preferences>PyDev>Interpreter>Python
  • Select all but the PySrc and python32.zip and click OK as many times as necessary to exit the preferences. The default selection should be fine.
  • Create new Python workplace for eclipse (D:\Eclipse\Python)
  • Import prerferences for Python workspace

 

 

 

                

  1. Launch Eclipse         
  1. Launch Eclipse. A screen like this should appear, where you can choose which workspace to open.(If not, go to File → Switch Workspace → Other )                                                 
  2. Screenshots read 'Python 3.1', which is the old version. You will be installing Python 3.2.

  1. Browse the csse120 folder which you created when installing Eclipse. Select "Use this as the default and do not ask again".                                                        
  1. If you do, Eclipse will automatically use this                                                         workspace next time you open Eclipse. If you want to change the workspace later you can always go to File → Switch Workspace... to be sent back to the Workspace Launcher window.
  1. You should now see Eclipse's Welcome screen:                                                                  
  2. Click on the arrow on the right to go to the workbench.                                                                                                  
  3. This is where you'll do most of your work in Eclipse.                        
  1. Download PyDev from within Eclipse                                 
  2. Go to Help → Install New Software

                                                         

  1. Enter http://pydev.org/updates in the Work with:  field.                                                 
  2. After several seconds, two options should appear. Select the PyDev for Eclipse option.
  3. Do not select the "PyDev Mylyn Integration" flag.                                                 
  4. Click "Next" and "OK" to continue installing PyDev.                                         
  5. Select "I accept the terms of the license agreement", then click "Finish". The installer will begin to download the plug-in.                                 
  6. Note: When you see the Selection Needed dialog box, you must manually check thebox before pressing okay. If you do not, it appears that the installation is continuing, but it is not. You must uninstall PyDev, then reinstall.                                         

 

  1. A security warning may appear asking whether you trust the software being installed-click "ok", then ensure the correct items are selected and click yes. The         instillation process will continue.
  2. When the installation is complete, you will be asked if you want to restart Eclipse. Select "Yes". You may see a Subclipse Usage  dialog, just uncheck the box and continue.

 

 

SVN

  1. VisualSVN
  2. TurtoiseSVN (causes lock issues with Eclipse sooo...)
  3. Install Software: Eclipse > Subclipse
    Name: Subclipse 1.6.x (Eclipse 3.2+)
    URL:  
    http://subclipse.tigris.org/update_1.6.x

 

 

Selenium Setup

 

Python SetupTools

 

C:\Python27\PySetupTools>ez_setup.py

Downloading http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-p

y2.7.egg

Processing setuptools-0.6c11-py2.7.egg

Copying setuptools-0.6c11-py2.7.egg to c:\python27\lib\site-packages

Adding setuptools 0.6c11 to easy-install.pth file

Installing easy_install-script.py script to C:\Python27\Scripts

Installing easy_install.exe script to C:\Python27\Scripts

Installing easy_install.exe.manifest script to C:\Python27\Scripts

Installing easy_install-2.7-script.py script to C:\Python27\Scripts

Installing easy_install-2.7.exe script to C:\Python27\Scripts

Installing easy_install-2.7.exe.manifest script to C:\Python27\Scripts

 

Installed c:\python27\lib\site-packages\setuptools-0.6c11-py2.7.egg

Processing dependencies for setuptools==0.6c11

Finished processing dependencies for setuptools==0.6c11

 

Python Package Index

 

C:\Python27\pipInstaller>get-pip.py

Downloading/unpacking pip

  Downloading pip-1.1.tar.gz (95Kb): 95Kb downloaded

  Running setup.py egg_info for package pip

 

        warning: no files found matching '*.html' under directory 'docs'

        warning: no previously-included files matching '*.txt' found under directory

 'docs\_build'

        no previously-included directories found matching 'docs\_build\_sources'

Installing collected packages: pip

  Running setup.py install for pip

 

        warning: no files found matching '*.html' under directory 'docs'

        warning: no previously-included files matching '*.txt' found under directory

 'docs\_build'

        no previously-included directories found matching 'docs\_build\_sources'

        Installing pip-script.py script to C:\Python27\Scripts

        Installing pip.exe script to C:\Python27\Scripts

        Installing pip.exe.manifest script to C:\Python27\Scripts

        Installing pip-2.7-script.py script to C:\Python27\Scripts

        Installing pip-2.7.exe script to C:\Python27\Scripts

        Installing pip-2.7.exe.manifest script to C:\Python27\Scripts

Successfully installed pip

Cleaning up...

 

Python Selenium Client

  • pip install -U selenium

C:\Python27\Scripts>pip install -U selenium

Downloading/unpacking selenium

  Downloading selenium-2.25.0.tar.gz (2.0Mb): 2.0Mb downloaded

  Running setup.py egg_info for package selenium

        C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution opt

ion: 'src_root'

          warnings.warn(msg)

 

        warning: no files found matching 'docs\api\py\index.rst'

Installing collected packages: selenium

  Running setup.py install for selenium

        C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution opt

ion: 'src_root'

          warnings.warn(msg)

 

        warning: no files found matching 'docs\api\py\index.rst'

Successfully installed selenium

Cleaning up...

Python Java Server

Selenium IDE

Selenium IDE is a Firefox plugin that does record-and-playback of interactions with the browser. Use this to either create simple scripts, assist in exploratory testing. It can also export Remote Control or WebDriver scripts, though they tend to be somewhat brittle and should be overhauled into some sort of Page Object-y structure for any kind of resiliency.

Download version 1.9.0 released on 24/July/2012 or view the Release Notes

Selenium Server (formerly the Selenium RC Server)

The Selenium Server is needed in order to run either Selenium RC style scripts or Remote Selenium Webdriver ones. The 2.x server is a drop-in replacement for the old Selenium RC server and is designed to be backwards compatible with your existing infrastructure.

Download version 2.25.0

To use the Selenium Server in a Grid configuration see the wiki page.

The Internet Explorer Driver Server

This is required if you want to make use of the latest and greatest features of the WebDriver InternetExplorerDriver. Please make sure that this is available on your $PATH (or %PATH% on Windows) in order for the IE Driver to work as expected.

Download version 2.24.2 for (recommended) 32 bit Windows IE or 64 bit Windows IE

Selenium Client Drivers(python selenium library/service)

In order to create scripts that interact with the Selenium Server (Selenium RC, Selenium Remote Webdriver) or create local Selenium WebDriver script you need to make use of language-specific client drivers. Unless otherwise specified, drivers include both 1.x and 2.x style drivers.

While drivers for other languages exist, these are the core ones that are supported by the main project.

Language

Client Version

Release Date

 

 

 

Java

2.25.0

2012-07-18

Download 

Change log 

Javadoc

C#

2.24.0

2012-06-19

Download

Change log

API docs

Ruby

2.24.0

2012-06-19

Download

Change log

API docs

Python

2.24.0

2012-06-19

Download

Change log

API docs

 

Selenium Python API/Usage

http://pypi.python.org/pypi/selenium/

 

 

 

 

Example

from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.common.keys import Keys
import time

browser = webdriver.Firefox() # Get local session of firefox
browser.get("http://www.yahoo.com") # Load page
assert "Yahoo!" in browser.title
elem = browser.find_element_by_name("p") # Find the query box
elem.send_keys("seleniumhq" + Keys.RETURN)
time.sleep(0.2) # Let the page load, will be added to the API
try:
   browser.find_element_by_xpath("//a[contains(@href,'http://seleniumhq.org')]")
except NoSuchElementException:
   assert 0, "can't find seleniumhq"
browser.close()

Documentation

Auto Generated API

 

Tags