---
title: Export Selenium IDE Tests to Code, and When to Graduate
description: Every Selenium IDE command maps to a Selenium WebDriver call, so the
  IDE can write your tests out as code. It is a good way to see what a recorded test…
source_url:
  html: https://testingbot.com/resources/courses/selenium-ide/export-to-code
  md: https://testingbot.com/resources/courses/selenium-ide/export-to-code.md
---

Course

[Selenium IDE: Codeless Test Automation](https://testingbot.com/resources/courses/selenium-ide)

Chapter 9 of 10

1. [1 Selenium IDE Tutorial: Codeless Test Automation](https://testingbot.com/resources/courses/selenium-ide)
2. [2 Install Selenium IDE and Record Your First Test](https://testingbot.com/resources/courses/selenium-ide/install-and-record-your-first-test)
3. [3 Commands, Targets and Locators in Selenium IDE](https://testingbot.com/resources/courses/selenium-ide/commands-targets-and-locators)
4. [4 Assertions, Verifications and Waits in Selenium IDE](https://testingbot.com/resources/courses/selenium-ide/assertions-verifications-and-waits)
5. [5 Variables, store and Control Flow in Selenium IDE](https://testingbot.com/resources/courses/selenium-ide/variables-and-control-flow)
6. [6 Reusing Tests and Organising Suites in Selenium IDE](https://testingbot.com/resources/courses/selenium-ide/reusing-tests-and-suites)
7. [7 Run .side Files with selenium-side-runner](https://testingbot.com/resources/courses/selenium-ide/run-side-files-with-selenium-side-runner)
8. [8 Run Selenium IDE Tests on the TestingBot Grid](https://testingbot.com/resources/courses/selenium-ide/run-on-testingbot)
9. [9 Export Selenium IDE Tests to Code, and When to Graduate](https://testingbot.com/resources/courses/selenium-ide/export-to-code)
10. [10 Knowledge check](https://testingbot.com/resources/courses/selenium-ide/knowledge-check)

[Exit course](https://testingbot.com/resources/courses)

 Chapter 9 of 10 Beginner 6 min read 1 quick check Updated Nov 2026 

# Export Selenium IDE Tests to Code, and When to Graduate
On this page
1. [How to export](https://testingbot.com#how-to-export)
2. [What came out](https://testingbot.com#what-came-out)
3. [What the export gets wrong](https://testingbot.com#what-the-export-gets-wrong)
4. [What the cleaned-up version looks like](https://testingbot.com#what-the-cleaned-up-version-looks-like)
5. [When to graduate from the IDE](https://testingbot.com#when-to-graduate-from-the-ide)
6. [Where to go next](https://testingbot.com#where-to-go-next)

Every Selenium IDE command maps to a Selenium WebDriver call, so the IDE can write your tests out as code. It is a good way to see what a recorded test really does, and a reasonable first step when a suite has outgrown the table. It is not a finished test suite. This chapter exports the course project to Python, runs what came out, and shows what had to change.

## How to export[#](https://testingbot.com#how-to-export)

In the IDE, right-click a test in the **Tests** tab and choose **Export test(s) to**, or right-click a suite in the **Suites** tab and choose **Export suite(s) to**, then pick a language. Version 4.1.0-beta.3 ships exporters for:

| Language | Test framework |
| --- | --- |
| Java | JUnit |
| Python | pytest |
| JavaScript | Mocha |
| Ruby | RSpec |
| C# | NUnit and xUnit |

The exporters are separate npm packages (such as `@seleniumhq/code-export-python-pytest`), and the IDE uses the same packages. We ran the 4.1.0-beta.3 exporters from the command line on `the-internet.side`, once per test and once per suite, and ran the Python results with pytest 9 and Selenium 4.52.

**Export suites, not single tests, when they use `run`.** The per-test export of "Log in and log out" called `self.login()` but did not contain a `login` method, so it failed with `AttributeError: 'TestLoginandlogout' object has no attribute 'login'`. The suite export wrote the shared `Log in` test as a `login` method in the same class.

## What came out[#](https://testingbot.com#what-came-out)

Here is the exported "Log in with valid credentials", unedited:

```python
# Generated by Selenium IDE
import pytest
import time
import json
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

class TestLoginwithvalidcredentials():
  
  def setup_method(self, method):
    self.driver = webdriver.Chrome()
    self.vars = {}
  
  def teardown_method(self, method):
    self.driver.quit()
  
  def test_loginwithvalidcredentials(self):
    self.driver.get("https://the-internet.herokuapp.com/login")
    self.driver.find_element(By.ID, "username").send_keys("tomsmith")
    self.driver.find_element(By.ID, "password").send_keys("SuperSecretPassword!")
    self.driver.find_element(By.CSS_SELECTOR, ".radius").click()
    elements = self.driver.find_elements(By.CSS_SELECTOR, "#flash.success")
    assert len(elements) > 0
    assert self.driver.find_element(By.CSS_SELECTOR, "h2").text == "Secure Area"
    # Only on TestingBot: name the session and mark it passed
    if self.driver.execute_script("return (arguments[0] === 'yes')", self.vars["env:TB_REPORT"]):
      pass
```

The commands are all there and readable, which is the value of the export. Then we ran it, and all eight exported tests failed.

## What the export gets wrong[#](https://testingbot.com#what-the-export-gets-wrong)

**1. Waiting is lost.** In the IDE, `assertElementPresent` waits up to the step timeout for the element. The export checks once, straight after the click:

```
> assert len(elements) > 0
E assert 0 > 0
```

The secure page had not loaded yet. This is the timing problem from chapter 3 again, and the reason a recorded test that is solid in the IDE can be flaky as code. Commands with `waitFor` in their name do become waits (`waitForElementVisible` turned into a `WebDriverWait` with `visibility_of_element_located`), but the implicit waiting of other commands does not carry over.

**2. Environment variables are not translated.** `${env:TB_REPORT}` became `self.vars["env:TB_REPORT"]`, a dictionary key that never exists:

```
E KeyError: 'env:TB_REPORT'
```

And the two `executeScript` steps inside that `if` were dropped; the block only contains `pass`.

**3. Some commands are dropped.** In "Store and reuse values", `storeTitle | pageTitle` produced no line at all, so the next assertion failed with `KeyError: 'pageTitle'`.

**4. The browser is hard-coded.** `setup_method` always starts a local `webdriver.Chrome()`. There is no option for Firefox or a remote grid.

**5. The structure is one class per file with names like `TestLoginwithvalidcredentials`** , copies of the same locators in every test, and no fixtures.

The Java export has the same shape. One extra trap there: it checks element presence with Java's `assert` keyword, which the JVM skips unless you start it with `-ea`, so that check silently does nothing.

None of this makes the export useless. Treat it as a translation draft: it tells you which WebDriver calls a recorded step corresponds to, and you rewrite it into a proper test.

A test that never fails in the IDE fails now and then after export, on a line that checks an element straight after a click. Why?

 The exported code uses a different locator than the IDE The IDE waited for the element up to the step timeout; the exported check runs once, before the next page has loaded pytest runs the steps in a different order

The locator is the same; the waiting is not. Add an explicit wait (`WebDriverWait` with an expected condition) for something that only exists after the click.

## What the cleaned-up version looks like[#](https://testingbot.com#what-the-cleaned-up-version-looks-like)

The same two login tests, rewritten by hand. A pytest fixture owns the browser, the login is a function with parameters instead of a `run` with stored variables, and each check waits for the page it needs:

```python
import pytest
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait

BASE_URL = "https://the-internet.herokuapp.com"

@pytest.fixture
def driver():
    driver = webdriver.Chrome()
    yield driver
    driver.quit()

def log_in(driver, username, password):
    driver.get(f"{BASE_URL}/login")
    driver.find_element(By.ID, "username").send_keys(username)
    driver.find_element(By.ID, "password").send_keys(password)
    driver.find_element(By.CSS_SELECTOR, ".radius").click()

def test_log_in_with_valid_credentials(driver):
    log_in(driver, "tomsmith", "SuperSecretPassword!")
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "#flash.success")))
    assert driver.find_element(By.CSS_SELECTOR, "h2").text == "Secure Area"

def test_wrong_password_shows_an_error(driver):
    log_in(driver, "tomsmith", "not-the-password")
    WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CSS_SELECTOR, "#flash.error")))
    assert not driver.find_elements(By.CSS_SELECTOR, "#flash.success")
```

```
$ pytest -q test_login.py
2 passed in 5.65s
```

It passed three runs in a row with Selenium 4.52.0. The next steps, a browser option, a remote grid and page objects, are what the code courses below teach.

## When to graduate from the IDE[#](https://testingbot.com#when-to-graduate-from-the-ide)

There is no line count at which you must switch. These are the signals that the table is costing more than it saves:

- **You store five variables before every `run`.** You want functions with parameters.
- **The same locator is in twenty tests.** When it changes, you want to fix it in one place: that is a page object.
- **Tests need data you cannot click together** : a fresh user from an API, rows in a database, values from a file.
- **Several people edit the suite.** JSON diffs and merge conflicts in `.side` files are painful; code reviews are not.
- **`executeScript` steps are growing.** JavaScript in a table cell is code without an editor, linting or tests.

A common and healthy split is to keep a small Selenium IDE smoke suite that non-developers own, and write the rest in code.

## Where to go next[#](https://testingbot.com#where-to-go-next)

Pick the course for the language your team uses. Each one starts from an empty folder and ends on a cloud grid:

- **Python** : [Selenium with Python and pytest](https://testingbot.com/resources/courses/selenium-python), the natural next step after this chapter's example.
- **Java** : [Selenium with TestNG](https://testingbot.com/resources/courses/selenium-testng), for Java teams and Maven projects.
- **Structure** : [Page Object Model](https://testingbot.com/resources/courses/page-object-model), the pattern that solves "the same locator in twenty tests".
- **Browsers** : [Cross-Browser Testing](https://testingbot.com/resources/courses/cross-browser-testing), when the question becomes which browsers to test and why they differ.

[Previous · Chapter 8 Run Selenium IDE Tests on the TestingBot Grid](https://testingbot.com/resources/courses/selenium-ide/run-on-testingbot) [Next · Chapter 10 Knowledge check](https://testingbot.com/resources/courses/selenium-ide/knowledge-check)

On this page

1. [How to export](https://testingbot.com#how-to-export)
2. [What came out](https://testingbot.com#what-came-out)
3. [What the export gets wrong](https://testingbot.com#what-the-export-gets-wrong)
4. [What the cleaned-up version looks like](https://testingbot.com#what-the-cleaned-up-version-looks-like)
5. [When to graduate from the IDE](https://testingbot.com#when-to-graduate-from-the-ide)
6. [Where to go next](https://testingbot.com#where-to-go-next)

Certification

Earn the free, resume-worthy TestingBot Selenium IDE Certification for this course.

[How it works](https://testingbot.com/resources/courses/selenium-ide/certification)
