Use python to drive selenium RC

Source: Internet
Author: User

Selenium RC supports multiple typesProgramming LanguageDriver client browser. This section describes how to use python to drive selenium RC in windows. Python is an object-oriented computer.ProgramDesign Language.

1. preparations:

Download Java: currently 1.6 update7,: http://www.java.com/zh_CN/

Download Python: the current stable version is 2.5.2, http://www.python.org/download/. for information about python, see http://www.python.org/

Download selenium RC: currently version 1.0 beta1,: http://selenium-rc.openqa.org/download.html,Selenium RC see: http://selenium-rc.openqa.org/

2. Start running

    • Start selenium server and decompress the downloaded selenium RC. A folder named selenium-server-1.0-beta-1 is displayed, which is the storage directory of selenium server, start the selenium Server Service through the Java-jar selenium-server.jar,

    • Taking Google's search for Hello world as an example, the Python script is as follows:

"* Firefox" is a supported browser or a browser called by selenium RC. Selenium supports the following browser types,

Supported browsers include:
* Iexplore
* Konqueror
* Firefox
* Mock
* Pifirefox
* Piistme
* Chrome
* Safari
* Opera
* Iehta
* Custom

Here, only * iexplore or * Firefox indicates that the browser is installed in the default path, that is, ie is installed in "C: \ Program Files \ Internet Explorer \ iexplore.exe ", firefox is installed in "C: \ Program Files \ Mozilla Firefox \ firefox.exe ". If it is not installed in the default path, you must specify the address of the browser installation, for example, "* Firefox D: \ Program Files \ Mozilla Firefox \ firefox.exe ".

"Def teardown (Self ):
Self. Selenium. Stop ()"

This section indicates that the browser is closed directly after running. You can comment it out here.

    • First, run it once for the browser using IE,CodeAs follows:

Click the run module or the shortcut key F5 from the run menu drop-down menu on the python ide to start running the Python code. Use selenium to directly call IE to run the client.

At the same time, the command line window displays each step performed by selenium Server

 

    • Next, use Firefox as the browser to access

Modify the code. * iexplore "is changed to" * Custom D: \ Program Files \ Mozilla Firefox \ firefox.exe "because Firefox on my computer is version 3.0, currently, selenium RC does not support this version. Neither "* Chrome" nor "* Firefox" can be called out. However, if Firefox is earlier than version 3.0 on your machine, you can directly use the "* Chrome" parameter.

Before running, set the proxy in Firefox to be consistent with selenium server, localhost, and port 4444.

 

For other browsers, you only need to modify the corresponding parameters such as * safari or * opera to call the access function to test compatibility of multiple browsers.

Other problemsArticle:

Running selenium in Python Driven Mode

Http://agiletesting.blogspot.com/2006/01/running-s...

Web app testing with python part 1: maxq

Http://agiletesting.blogspot.com/2005/02/web-app-testing-with-python-part-1.html

Web app testing with python part 2: Selenium and twisted

Http://agiletesting.blogspot.com/2005/03/web-app-testing-with-python-part-2.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.