Python Development Workbook
- Eclipse Juno
- PyDev AddOn:
- Help > Install New Software: http://pydev.org/updates
- 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
-
Launch Eclipse
- Launch Eclipse. A screen like this should appear, where you can choose which workspace to open.(If not, go to File → Switch Workspace → Other )
- Screenshots read 'Python 3.1', which is the old version. You will be installing Python 3.2.
- Browse the csse120 folder which you created when installing Eclipse. Select "Use this as the default and do not ask again".
- 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.
- You should now see Eclipse's Welcome screen:
- Click on the arrow on the right to go to the workbench.
- This is where you'll do most of your work in Eclipse.
-
Download PyDev from within Eclipse
- Go to Help → Install New Software
- Enter http://pydev.org/updates in the Work with: field.
- After several seconds, two options should appear. Select the PyDev for Eclipse option.
- Do not select the "PyDev Mylyn Integration" flag.
- Click "Next" and "OK" to continue installing PyDev.
- Select "I accept the terms of the license agreement", then click "Finish". The installer will begin to download the plug-in.
- 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.
- 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.
- 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
- VisualSVN
- TurtoiseSVN (causes lock issues with Eclipse sooo...)
- 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
- http://pypi.python.org/pypi/setuptools
- Unpacks to \Python27\Scripts
- run: ez_setup.py
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
- http://pypi.python.org/pypi/pip/
- http://www.pip-installer.org/en/latest/installing.html
- run: python get-pip.py
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
- Download the server from http://selenium.googlecode.com/files/selenium-server-standalone-2.25.0.jar
- run: java -jar selenium-server-standalone-2.25.0.jar
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 |
|||
C# |
2.24.0 |
2012-06-19 |
|||
Ruby |
2.24.0 |
2012-06-19 |
|||
Python |
2.24.0 |
2012-06-19 |
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
- Log in to post comments