Learn about Selenium testing with CrossBrowserTesting.
In This Section
What is Selenium?
Selenium is an open source testing tool that allows users to test web applications across different browsers and platforms. Selenium includes a suite of software that developers can use to automate web applications including IDE, RC, WebDriver and Selenium grid, which all serve different purposes.
In this post, we will explore the multiple components of the Selenium testing framework and its evolution as well as how it's used and why developers and testers depend on it for browser testing.
What is the use?
The uses of Selenium increase as you advance in the suite, and each component has advantages and disadvantages. The basic fundamentals of Selenium though revolve around browser testing, as developers and testers alike love the open source framework's ability to mimic a real user’s actions in the browser. Developers create test scripts that run locally or in the cloud to assess basic functional correctness and verify visual layouts. These test scripts can range from simple JavaScript unit tests around an action like a button click, or fully automated end-to-end functional tests that resemble the full actions of an everyday user, like the checkout or login process.
What makes Selenium so easy to learn is its ability to bind to several popular languages, letting you write in your preferred programming language including Java, JavaScript, PHP, Perl, C#, Ruby, .NET, and Python.
A brief history of Selenium
Selenium has a dynamic history since it came to being in 2004 when Jason Huggins, who was a ThoughtWorks programmer at the time, decided to make a tool for testing web applications. By the end of the year, it had become a wildly popular open source tool.
The first version of Selenium had many limiting factors like its JavaScript based automation engine, causing Huggins to seek other contributors. Simon Stewart, another ThoughtWorks employee, stepped up to the plate and they produced Selenium WebDriver, or Selenium 2.0
The combination of Selenium and WebDriver in 2006 became a primary web application tool know as Selenium 2.0 and is one of the leading free testing tools for programmers around the world.
While Selenium 3.0 has been released, it's basically a new and improved version of Selenium 2.0 with the same fundamental purpose and structure.
Breaking down the Selenium suite
The beginning – Selenium IDE
Selenium IDE (Integrated Development Environment) is the Firefox plug-in tool that allows you to record, playback, edit and debug test scripts to export them in a preferred programming language. By providing a test domain specific language, Selenese, IDE lets you test without learning a new scripting language and makes it easier to send commands to the browser and automate testing. However, IDE is limiting in the way that you can only use it to test web applications in Firefox, and therefore it cannot be used to test other browsers.
Selenium IDE is mostly used now for bug reproduction scripts, exploratory testing, learning about Selenese commands and exporting simple test cases to WebDriver. Selenium Builder is also a Firefox extension that can import HTML files recorded in Selenium IDE to run tests locally or on a Selenium server and further assist automation.
The Evolution - Selenium 1 and 2
Selenium RC (Remote Control), or Selenium 1, was a method used to run the test script in different browsers by launching them as a proxy server, but has since been abandoned since the creation of WebDriver, or Selenium 2.0. Selenium 2 is what you would use in testing today, as RC is no longer supported.
This is because WebDriver doesn't rely on JavaScript for automation like RC does, and instead, directly communicates with the browser from the operating system making it faster and more accurate. WebDriver also supports more browsers and operating environments than RC including the HtmlUnit browser, and has a more concise API.
Selenium 2 is popular among developers and QA teams for regressions tests and cross browser testing, since it allows you to test on a spectrum of browsers and operating systems using the native operating system functionality. This means that commands perform as a human would if they were using the same browser.
Optimization - Selenium Grid
Selenium Grid allows you to multiple run tests at the same time on different machines and browsers in order to speed up testing. For CI motions, testing demands to be done at a rapid pace, and running tests sequentially can be painfully slow. Running in parallel on a grid can improve the speed of your testing greatly. Selenium Grid is comprised of one machine called a hub and multiple nodes for execution. The more nodes you have, the more tests you can run simultaneously.
While you can make your own Selenium grid with a costly device lab or VMs, many have found moving Selenium grid to a third-party cloud is faster and more productive, allowing more tests to run on more OS systems and browsers simultaneously.
Exhaustive list of Selenium commands
-
addLocationStrategy
-
addLocationStrategyAndWait
-
addScript
-
addScriptAndWait
-
addSelection
-
addSelectionAndWait
-
allowNativeXpath
-
allowNativeXpathAndWait
-
altKeyDown
-
altKeyDownAndWait
-
altKeyUp
-
altKeyUpAndWait
-
answerOnNextPrompt
-
assertAlert
-
assertAlertNotPresent
-
assertAlertPresent
-
assertAllButtons
-
assertAllFields
-
assertAllLinks
-
assertAllWindowIds
-
assertAllWindowNames
-
assertAllWindowTitles
-
assertAttribute
-
assertAttributeFromAllWindows
-
assertBodyText
-
assertChecked
-
assertConfirmation
-
assertConfirmationNotPresent
-
assertConfirmationPresent
-
assertCookie
-
assertCookieByName
-
assertCookieNotPresent
-
assertCookiePresent
-
assertCursorPosition
-
assertEditable
-
assertElementHeight
-
assertElementIndex
-
assertElementNotPresent
-
assertElementPositionLeft
-
assertElementPositionTop
-
assertElementPresent
-
assertElementWidth
-
assertEval
-
assertExpression
-
assertHtmlSource
-
assertLocation
-
assertMouseSpeed
-
assertNotAlert
-
assertNotAllButtons
-
assertNotAllFields
-
assertNotAllLinks
-
assertNotAllWindowIds
-
assertNotAllWindowNames
-
assertNotAllWindowTitles
-
assertNotAttribute
-
assertNotAttributeFromAllWindows
-
assertNotBodyText
-
assertNotChecked
-
assertNotConfirmation
-
assertNotCookie
-
assertNotCookieByName
-
assertNotCursorPosition
-
assertNotEditable
-
assertNotElementHeight
-
assertNotElementIndex
-
assertNotElementPositionLeft
-
assertNotElementPositionTop
-
assertNotElementWidth
-
assertNotEval
-
assertNotExpression
-
assertNotHtmlSource
-
assertNotLocation
-
assertNotMouseSpeed
-
assertNotOrdered
-
assertNotPrompt
-
assertNotSelectOptions
-
assertNotSelectedId
-
assertNotSelectedIds
-
assertNotSelectedIndex
-
assertNotSelectedIndexes
-
assertNotSelectedLabel
-
assertNotSelectedLabels
-
assertNotSelectedValue
-
assertNotSelectedValues
-
assertNotSomethingSelected
-
assertNotSpeed
-
assertNotTable
-
assertNotText
-
assertNotTitle
-
assertNotValue
-
assertNotVisible
-
assertNotWhetherThisFrameMatchFrameExpression
-
assertNotWhetherThisWindowMatchWindowExpression
-
assertNotXpathCount
-
assertOrdered
-
assertPrompt
-
assertPromptNotPresent
-
assertPromptPresent
-
assertSelectOptions
-
assertSelectedId
-
assertSelectedIds
-
assertSelectedIndex
-
assertSelectedIndexes
-
assertSelectedLabel
-
assertSelectedLabels
-
assertSelectedValue
-
assertSelectedValues
-
assertSomethingSelected
-
assertSpeed
-
assertTable
-
assertText
-
assertTextNotPresent
-
assertTextPresent
-
assertTitle
-
assertValue
-
assertVisible
-
assertWhetherThisFrameMatchFrameExpression
-
assertWhetherThisWindowMatchWindowExpression
-
assertXpathCount
-
assignId
-
assignIdAndWait
-
break
-
captureEntirePageScreenshot
-
captureEntirePageScreenshotAndWait
-
check
-
checkAndWait
-
chooseCancelOnNextConfirmation
-
chooseOkOnNextConfirmation
-
chooseOkOnNextConfirmationAndWait
-
click
-
clickAndWait
-
clickAt
-
clickAtAndWait
-
close
-
contextMenu
-
contextMenuAndWait
-
contextMenuAt
-
contextMenuAtAndWait
-
controlKeyDown
-
controlKeyDownAndWait
-
controlKeyUp
-
controlKeyUpAndWait
-
createCookie
-
createCookieAndWait
-
deleteAllVisibleCookies
-
deleteAllVisibleCookiesAndWait
-
deleteCookie
-
deleteCookieAndWait
-
deselectPopUp
-
deselectPopUpAndWait
-
doubleClick
-
doubleClickAndWait
-
doubleClickAt
-
doubleClickAtAndWait
-
dragAndDrop
-
dragAndDropAndWait
-
dragAndDropToObject
-
dragAndDropToObjectAndWait
-
dragdrop
-
dragdropAndWait
-
echo
-
fireEvent
-
fireEventAndWait
-
focus
-
focusAndWait
-
goBack
-
goBackAndWait
-
highlight
-
highlightAndWait
-
ignoreAttributesWithoutValue
-
ignoreAttributesWithoutValueAndWait
-
keyDown
-
keyDownAndWait
-
keyPress
-
keyPressAndWait
-
keyUp
-
keyUpAndWait
-
metaKeyDown
-
metaKeyDownAndWait
-
metaKeyUp
-
metaKeyUpAndWait
-
mouseDown
-
mouseDownAndWait
-
mouseDownAt
-
mouseDownAtAndWait
-
mouseDownRight
-
mouseDownRightAndWait
-
mouseDownRightAt
-
mouseDownRightAtAndWait
-
mouseMove
-
mouseMoveAndWait
-
mouseMoveAt
-
mouseMoveAtAndWait
-
mouseOut
-
mouseOutAndWait
-
mouseOver
-
mouseOverAndWait
-
mouseUp
-
mouseUpAndWait
-
mouseUpAt
-
mouseUpAtAndWait
-
mouseUpRight
-
mouseUpRightAndWait
-
mouseUpRightAt
-
mouseUpRightAtAndWait
-
open
-
openWindow
-
openWindowAndWait
-
pause
-
refresh
-
refreshAndWait
-
removeAllSelections
-
removeAllSelectionsAndWait
-
removeScript
-
removeScriptAndWait
-
removeSelection
-
removeSelectionAndWait
-
rollup
-
rollupAndWait
-
runScript
-
runScriptAndWait
-
select
-
selectAndWait
-
selectFrame
-
selectPopUp
-
selectPopUpAndWait
-
selectWindow
-
sendKeys
-
setBrowserLogLevel
-
setBrowserLogLevelAndWait
-
setCursorPosition
-
setCursorPositionAndWait
-
setMouseSpeed
-
setMouseSpeedAndWait
-
setSpeed
-
setSpeedAndWait
-
setTimeout
-
shiftKeyDown
-
shiftKeyDownAndWait
-
shiftKeyUp
-
shiftKeyUpAndWait
-
store
-
storeAlert
-
storeAlertPresent
-
storeAllButtons
-
storeAllFields
-
storeAllLinks
-
storeAllWindowIds
-
storeAllWindowNames
-
storeAllWindowTitles
-
storeAttribute
-
storeAttributeFromAllWindows
-
storeBodyText
-
storeChecked
-
storeConfirmation
-
storeConfirmationPresent
-
storeCookie
-
storeCookieByName
-
storeCookiePresent
-
storeCursorPosition
-
storeEditable
-
storeElementHeight
-
storeElementIndex
-
storeElementPositionLeft
-
storeElementPositionTop
-
storeElementPresent
-
storeElementWidth
-
storeEval
-
storeExpression
-
storeHtmlSource
-
storeLocation
-
storeMouseSpeed
-
storeOrdered
-
storePrompt
-
storePromptPresent
-
storeSelectOptions
-
storeSelectedId
-
storeSelectedIds
-
storeSelectedIndex
-
storeSelectedIndexes
-
storeSelectedLabel
-
storeSelectedLabels
-
storeSelectedValue
-
storeSelectedValues
-
storeSomethingSelected
-
storeSpeed
-
storeTable
-
storeText
-
storeTextPresent
-
storeTitle
-
storeValue
-
storeVisible
-
storeWhetherThisFrameMatchFrameExpression
-
storeWhetherThisWindowMatchWindowExpression
-
storeXpathCount
-
submit
-
submitAndWait
-
type
-
typeAndWait
-
typeKeys
-
typeKeysAndWait
-
uncheck
-
uncheckAndWait
-
useXpathLibrary
-
useXpathLibraryAndWait
-
verifyAlert
-
verifyAlertNotPresent
-
verifyAlertPresent
-
verifyAllButtons
-
verifyAllFields
-
verifyAllLinks
-
verifyAllWindowIds
-
verifyAllWindowNames
-
verifyAllWindowTitles
-
verifyAttribute
-
verifyAttributeFromAllWindows
-
verifyBodyText
-
verifyChecked
-
verifyConfirmation
-
verifyConfirmationNotPresent
-
verifyConfirmationPresent
-
verifyCookie
-
verifyCookieByName
-
verifyCookieNotPresent
-
verifyCookiePresent
-
verifyCursorPosition
-
verifyEditable
-
verifyElementHeight
-
verifyElementIndex
-
verifyElementNotPresent
-
verifyElementPositionLeft
-
verifyElementPositionTop
-
verifyElementPresent
-
verifyElementWidth
-
verifyEval
-
verifyExpression
-
verifyHtmlSource
-
verifyLocation
-
verifyMouseSpeed
-
verifyNotAlert
-
verifyNotAllButtons
-
verifyNotAllFields
-
verifyNotAllLinks
-
verifyNotAllWindowIds
-
verifyNotAllWindowNames
-
verifyNotAllWindowTitles
-
verifyNotAttribute
-
verifyNotAttributeFromAllWindows
-
verifyNotBodyText
-
verifyNotChecked
-
verifyNotConfirmation
-
verifyNotCookie
-
verifyNotCookieByName
-
verifyNotCursorPosition
-
verifyNotEditable
-
verifyNotElementHeight
-
verifyNotElementIndex
-
verifyNotElementPositionLeft
-
verifyNotElementPositionTop
-
verifyNotElementWidth
-
verifyNotEval
-
verifyNotExpression
-
verifyNotHtmlSource
-
verifyNotLocation
-
verifyNotMouseSpeed
-
verifyNotOrdered
-
verifyNotPrompt
-
verifyNotSelectOptions
-
verifyNotSelectedId
-
verifyNotSelectedIds
-
verifyNotSelectedIndex
-
verifyNotSelectedIndexes
-
verifyNotSelectedLabel
-
verifyNotSelectedLabels
-
verifyNotSelectedValue
-
verifyNotSelectedValues
-
verifyNotSomethingSelected
-
verifyNotSpeed
-
verifyNotTable
-
verifyNotText
-
verifyNotTitle
-
verifyNotValue
-
verifyNotVisible
-
verifyNotWhetherThisFrameMatchFrameExpression
-
verifyNotWhetherThisWindowMatchWindowExpression
-
verifyNotXpathCount
-
verifyOrdered
-
verifyPrompt
-
verifyPromptNotPresent
-
verifyPromptPresent
-
verifySelectOptions
-
verifySelectedId
-
verifySelectedIds
-
verifySelectedIndex
-
verifySelectedLabel
-
verifySelectedLabels
-
verifySelectedValue
-
verifySelectedValues
-
verifySomethingSelected
-
verifySpeed
-
verifyTable
-
verifyText
-
verifyTextNotPresent
-
verifyTextPresent
-
verifyTitle
-
verifyValue
-
verifyVisible
-
verifyWhetherThisFrameMatchFrameExpression
-
verifyWhetherThisWindowMatchWindowExpression
-
verifyXpathCount
-
waitForAlert
-
waitForAlertNotPresent
-
waitForAlertPresent
-
waitForAllButtons
-
waitForAllFields
-
waitForAllLinks
-
waitForAllWindowIds
-
waitForAllWindowNames
-
waitForAllWindowTitles
-
waitForAttribute
-
waitForAttributeFromAllWindows
-
waitForBodyText
-
waitForChecked
-
waitForCondition
-
waitForConfirmation
-
waitForConfirmationNotPresent
-
waitForConfirmationPresent
-
waitForCookie
-
waitForCookieByName
-
waitForCookieNotPresent
-
waitForCookiePresent
-
waitForCursorPosition
-
waitForEditable
-
waitForElementHeight
-
waitForElementIndex
-
waitForElementNotPresent
-
waitForElementPositionLeft
-
waitForElementPositionTop
-
waitForElementPresent
-
waitForElementWidth
-
waitForEval
-
waitForExpression
-
waitForFrameToLoad
-
waitForHtmlSource
-
waitForLocation
-
waitForMouseSpeed
-
waitForNotAlert
-
waitForNotAllButtons
-
waitForNotAllFields
-
waitForNotAllLinks
-
waitForNotAllWindowIds
-
waitForNotAllWindowNames
-
waitForNotAllWindowTitles
-
waitForNotAttribute
-
waitForNotAttributeFromAllWindows
-
waitForNotBodyText
-
waitForNotChecked
-
waitForNotConfirmation
-
waitForNotCookie
-
waitForNotCookieByName
-
waitForNotCursorPosition
-
waitForNotEditable
-
waitForNotElementHeight
-
waitForNotElementIndex
-
waitForNotElementPositionLeft
-
waitForNotElementPositionTop
-
waitForNotElementWidth
-
waitForNotEval
-
waitForNotExpression
-
waitForNotHtmlSource
-
waitForNotLocation
-
waitForNotMouseSpeed
-
waitForNotOrdered
-
waitForNotPrompt
-
waitForNotSelectOptions
-
waitForNotSelectedId
-
waitForNotSelectedIds
-
waitForNotSelectedIndex
-
waitForNotSelectedIndexes
-
waitForNotSelectedLabel
-
waitForNotSelectedLabels
-
waitForNotSelectedValue
-
waitForNotSelectedValues
-
waitForNotSomethingSelected
-
waitForNotSpeed
-
waitForNotTable
-
waitForNotText
-
waitForNotTitle
-
waitForNotValue
-
waitForNotVisible
-
waitForNotWhetherThisFrameMatchFrameExpression
-
waitForNotWhetherThisWindowMatchWindowExpression
-
waitForNotXpathCount
-
waitForOrdered
-
waitForPageToLoad
-
waitForPopUp
-
waitForPrompt
-
waitForPromptNotPresent
-
waitForPromptPresent
-
waitForSelectOptions
-
waitForSelectedId
-
waitForSelectedIds
-
waitForSelectedIndex
-
waitForSelectedIndexes
-
waitForSelectedLabel
-
waitForSelectedLabels
-
waitForSelectedValue
-
waitForSelectedValues
-
waitForSomethingSelected
-
waitForSpeed
-
waitForTable
-
waitForText
-
waitForTextNotPresent
-
waitForTextPresent
-
waitForTitle
-
waitForValue
-
waitForVisible
-
waitForWhetherThisFrameMatchFrameExpression
-
waitForWhetherThisWindowMatchWindowExpression
-
waitForXpathCount
-
windowFocus
-
windowFocusAndWait
-
windowMaximize
-
windowMaximizeAndWait