Using Selenium IDE

Overview

  • Support for Firefox and Chrome
    • Requires Firefox == 61 or newer
  • Records all interactions with browser
  • Can replay all recordings
  • Allows for multiple tests to be recorded
  • Used to have tons of useful features but newer version has dropped most of them
  • Older versions of Selenium IDE used to support exporting your tests to several formats, including Python
    • You could run the exported Python code and be done with it!
_images/selenium_ide_export_python.png
  • Now only JSON format seems to be supported
_images/selenium_ide_export_json.png
  • Requires creativity to ensure that playing back actions will wait for web elements to be present

How to install it

Firefox

  • Make sure that you’re using an updated version of Firefox.
    • I recommend Firefox Quantum version 61 or greater
    • You can have multiple versions running side by side; just rename the executable to Firefox45 for example

Important

If using an older version of Firefox, in order to preventing it from updating itself, you’ll have to disable the automatic update feature. To do that:

  • Immediately after starting Firefox, choose the Preferences menu
  • Check the Never check for updates (not recommended: security risk) option
_images/firefox-preferences.png

Google Chrome

Demo

Selenium IDE: Simple Test

Here’s an example of Googling for the term Red Hat and clicking the corresponding link.

_images/selenium_ide.png

This test can also be exported as JSON and be opened at a later time

{
"id": "b797dc14-e81e-4869-952f-678661776c02",
"name": "Untitled Project",
"url": "https://www.google.com",
"tests": [{
    "id": "c73764c1-67ef-477f-991a-35ff97a0652b",
    "name": "Untitled",
    "commands": [{
    "id": "59e5e648-0b92-4480-99ac-eeb3ba456433",
    "comment": "",
    "command": "open",
    "target": "/",
    "value": ""
    }, {
    "id": "083c23db-032b-4495-9947-b0668924d4a1",
    "comment": "",
    "command": "clickAt",
    "target": "id=lst-ib",
    "value": "16,16"
    }, {
    "id": "0c8489a7-9b1c-40ba-9967-3b79fc3e7107",
    "comment": "",
    "command": "clickAt",
    "target": "css=h3.r > a",
    "value": "19,15"
    }]
}],
"suites": [{
    "id": "22654ef7-6e89-46e9-bd19-247030d0db7d",
    "name": "Default Suite",
    "parallel": false,
    "timeout": 300,
    "tests": ["c73764c1-67ef-477f-991a-35ff97a0652b"]
}],
"urls": ["https://www.google.com/"],
"plugins": [],
"version": "1.0"
}

Selenium IDE: Better Test

Here’s the same example of Googling for the term Red Hat and clicking the corresponding link, but we’re explicitly setting the text that must be clicked on

_images/selenium_ide_better.png

This test can also be exported as JSON and be opened at a later time

{
"id": "51a034da-3929-4bca-8581-3869764da024",
"name": "Untitled Project",
"url": "https://www.google.com",
"tests": [{
    "id": "c5b80fac-3d33-4201-aa2e-28caa41f8f3b",
    "name": "Untitled",
    "commands": [{
    "id": "77f5e1a1-9363-4592-9cb2-a9c0dd67c520",
    "comment": "",
    "command": "open",
    "target": "/",
    "value": ""
    }, {
    "id": "22c0756b-ce6c-43af-bc12-1cb94bc85034",
    "comment": "",
    "command": "type",
    "target": "id=lst-ib",
    "value": "Red Hat"
    }, {
    "id": "a6368f72-3ccf-4592-96c8-68348739a453",
    "comment": "",
    "command": "sendKeys",
    "target": "id=lst-ib",
    "value": "${KEY_ENTER}"
    }, {
    "id": "c6b1c334-30b7-482f-a448-41eec304b504",
    "comment": "",
    "command": "assertText",
    "target": "css=h3.r > a",
    "value": "Red Hat - We make open source technologies for the enterprise"
    }, {
    "id": "0f0984fa-3a1c-47d5-80e1-275019e08ac1",
    "comment": "",
    "command": "clickAt",
    "target": "css=h3.r > a",
    "value": "Red Hat - We make open source technologies for the enterprise"
    }]
}],
"suites": [{
    "id": "23b8c9dd-03d5-4434-9646-21da2f664edd",
    "name": "Default Suite",
    "parallel": false,
    "timeout": 300,
    "tests": ["c5b80fac-3d33-4201-aa2e-28caa41f8f3b"]
}],
"urls": ["https://www.google.com/"],
"plugins": [],
"version": "1.0"
}