Selenium Tutorial

, , …,
Want to master JavaScript in a week? Buy Xah JavaScript Tutorial.

(this is my learning notes on Selenium)

Selenium (software) is a software to automate testing web sites. Basically, it simulates opening a web page, clicking, login, etc.

Selenium is a bit confusing. It has many different parts. Here's a summary:

What is Selenium IDE?

Selenium IDE (aka Selenium Recorder). (http://docs.seleniumhq.org/projects/ide/) is basically a recording tool (Firefox Add-On) for Firefox web browser. It lets you record clicks, etc and play it back. Good for learning Selenium, and useful for creating bug reproduction steps. This is the most basic tool, the origin of Selenium.

Selenium IDE 2014-01-29
Selenium IDE, Firefox plugin

the selenium IDE is very simple and toy-like. You can just start to use it, play with its buttons.

What is Selenese?

Selenese (Selenium IDE commands) is the commands/syntax (a small language) used in Selenium IDE. (see Selenese reference Selenium Reference) But you don't have to use it. You can use your {Python, Ruby, JavaScript, …}.

Selenium Remote Control?

Selenium Remote Control. (aka Selenium RC, Selenium 1) This is deprecated. Don't worry about this.

Selenium WebDriver?

Selenium WebDriver (Selenium 2). This basically the engine of Selenium. Available for all major browsers. The scripts in various languages calls Selenium API and talks to this WebDriver, and it in turn talks to the browser. This WebDriver was originally a different product, menat to be a standard for browser, and is in the process of becoming a w3c standard. See http://www.w3.org/TR/2013/WD-webdriver-20130117/

Selenium Client API?

Selenium Client API. This is library for different languages to talk to Selenium WebDriver, so you can write testing scripts in {Python, Ruby, JavaScript …} to control Selenium.


thnigs to try.

click on the record (red button) to start recording. (after you click on the record button, then, go to browser, let's say gmail.com, and try to login, after you login, switch back to the s ide and click stop recording.)

double click on a command runs that command.

click on the source tab to see the source code for your test.

right click on te “untitled *” under the left “Test Case” panel. You can name the test, and you can save the disk to disk. Try it.

Saving the Test

you can save the test as a standard SE xml file. Just go to File menu. the test file is basically just a HTML table.

this is the same as you click on the Source tab.

you can also save the test as a API webdrive script for Ruby, Python, etc. Just go to file menu and chose export.

try it.


you can right click on a web page to see all all the s commands.

Selenium WebDriver

misc

2014-02-01

download chrome driver blob at https://code.google.com/p/selenium/wiki/ChromeDriver

to use chrome driver, do

import os
from selenium.webdriver.chrome import options as chrome_opt
# driver = webdriver.Firefox()
driver = webdriver.Chrome(executable_path=os.path.join(os.getcwd(), "testing2/selenium/chromedriver"))

what's HtmlUnit?

HtmlUnit is a browser without a GUI interface. It's written in Java.

HtmlUnit home page @ http://htmlunit.sourceforge.net/

driver.get("http://www.google.com")

Selenium Reference

Official Selenium IDE tutorial @ http://docs.seleniumhq.org/docs/02_selenium_ide.jsp

Selenese (Selenium IDE commands) reference @ http://release.seleniumhq.org/selenium-core/1.0.1/reference.html. local copy: Selenium Reference

Selenium WebDriver into http://docs.seleniumhq.org/docs/03_webdriver.jsp

Selenium WebDriver Python API http://selenium.googlecode.com/git/docs/api/py/api.html.

Selenium WebDriver Python API (seems a older version) http://selenium.googlecode.com/svn/trunk/docs/api/py/index.html#documentation

https://code.google.com/p/selenium/

blog comments powered by Disqus