Endtest

Endtest

›Web Tests

Web Tests

  • How to create Web Tests
  • Finding elements in Web Applications
  • How to execute Web Tests
  • Assertions for Web Tests
  • IF Statements for Web Tests
  • Web Applications with restricted access
  • How to test in iframes
  • How to test in multiple tabs
  • How to test File Uploads
  • How to test File Downloads
  • How to test Emails
  • How to test PDF files
  • How to test Chrome Extensions
  • Dealing with reCAPTCHA
  • Dealing with Dynamic Locators
  • Dealing with Canvas Elements
  • Performing a Drag and Drop
  • Execute JavaScript
  • Testing WebRTC Applications
  • How to scroll in Web Tests
  • How to test Checkboxes
  • How to test Dropdowns
  • Dealing with Sessions
  • Web Crawler
  • Export Web Tests
  • Migrating from Selenium

Mobile Tests

  • How to create Mobile Tests
  • Finding elements in Mobile Applications
  • How to execute Mobile Tests
  • Assertions for Mobile Tests
  • IF Statements for Mobile Tests
  • How to scroll in Mobile Tests
  • Performing Complex Gestures

Advanced

  • Variables
  • Waits
  • Endtest API
  • Scheduler
  • Drive
  • Adding Collaborators
  • Computer Vision
  • Importing Test Cases
  • Using Loops
  • Data-driven Testing
  • Send API Requests
  • Read SMS
  • Execute SQL queries
  • Self-Healing Tests
  • Email Notifications
  • Slack Notifications
  • PagerDuty Notifications
  • Webhook Notifications
  • Automatic Backup
  • Advanced Settings
  • Multiple environments
  • How to stop a test
  • Utilities
  • Utilities API
  • Team
  • On-Premises

Integrations

  • Atlassian Jira
  • Slack
  • PagerDuty
  • Microsoft Teams
  • Mattermost
  • Jenkins
  • GitHub
  • Azure DevOps
  • GitLab
  • TeamCity
  • CircleCI
  • TravisCI
  • Bitbucket
  • Heroku
  • Bamboo Server
  • Test Case Management
  • SSO
  • BrowserStack
  • Sauce Labs

Migrating from Selenium

Introduction

You can migrate your existing Selenium tests to Endtest.

This process will convert those tests into standard Endtest codeless automated tests.

It doesn't matter if your existing Selenium tests are written in Java, Python, Ruby or C# or any other programming language.

The same process also works for any automated testing library or solution as long as you can execute those tests in a Chrome browser and you are able to load the Endtest Chrome Extension.

How it works

The Selenium migration uses our own Endtest Chrome Extension to record the steps from your existing Selenium tests.

But instead of using it to manually record a test, you will load it directly into your existing Selenium tests.

You just have to add a few steps at the start and at the end of your existing tests.

The steps added at the start of your test will automatically add our Endtest Chrome Extension in the Chrome browser in which you are executing your Selenium tests, log in to the extension and start the recording process.

The steps added at the end of your test will stop the recording and save the recorded steps into a new test case on Endtest.

Instructions

You will need to add the following instructions in your existing Selenium tests:

  1. Load the Endtest Chrome Extension in your test.
  2. Fetch the dynamic URL for the Endtest Chrome Extension and store it in a variable.
  3. Log in to the Endtest Chrome Extension with your Endtest credentials.
  4. Enter the Start from URL for your test.
  5. Click on the Start Recording button.
  6. Click on the Stop Recording button.
  7. Save your recorded test into your Endtest account.

Each element from our Endtest Chrome Extension has an ID and can be easily interacted with.

Here is the list of IDs for all the elements from our Endtest Chrome Extension:

SectionElementID
LoginEmail inputuserEmailLoginInput
LoginPassword inputuserPasswordLoginInput
LoginLog In buttonloginButton
AllSettings iconsettings_icon
SettingsRecord Scroll Events checkboxrecordScrollEventsCheckbox
SettingsRecord Hover Events checkboxrecordHoverEventsCheckbox
SettingsDon't use the "id" attribute checkboxdoNotUseIdAttribute
SettingsDon't use the "name" attribute checkboxdoNotUseNameAttribute
SettingsDon't use URL quert strings checkboxdoNotUseUrlQueryStrings
SettingsIgnore classes textareablacklist_classes
SettingsCustom data attributes textareacustom_data_attributes
SettingsDone buttondone_button
Before recordingStart from URL radio buttonstartFromUrlRadio
Before recordingStart from here radio buttonstartFromHereRadio
Before recordingURL inputurlInput
Before recordingStart Recording buttonstartRecordingButton
During recordingPause Recording buttonpauseRecordingButton
During recordingStop Recording buttonstopRecordingButton
During recordingTake Screenshot buttontakeScreenshotButton
During recordingAdd Assertion buttonaddAssertionButton
After recordingTest Case Name inputtestCaseNameInput
After recordingExisting Test Suite radio buttonexistingTestSuiteRadio
After recordingNew Test Suite radio buttonnewTestSuiteRadio
After recordingTest Suite Name inputnewTestSuiteName
After recordingChoose Test Suite selectselectTestSuite
After recordingSave buttonsaveRecordingButton
After recordingCancel buttoncancelRecordingButton

Example

Let's take a look at an example for migrating an existing Selenium test written in Python.

This is what the Selenium Python code looks like:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Configure and start the WebDriver
chromedriver = "C:\test\chromedriver.exe"

desired = DesiredCapabilities.CHROME
desired['loggingPrefs'] = {'browser': 'ALL','driver':  'ALL'}

options = webdriver.ChromeOptions()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')
options.add_argument("--unhandledPromptBehavior=accept")

driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=options,desired_capabilities=desired)

# Start the test
driver.get("https://swit.io/auth/register")

driver.find_element_by_id('firstName').send_keys("Saul")
driver.find_element_by_id('lastName').send_keys("Goodman")
driver.find_element_by_id('email').send_keys("saul@example.com")
driver.find_element_by_id('password').send_keys("RandomString@#987")

driver.find_element_by_id('signup').click()

# Quit the test
driver.quit()

We need to add the following steps in our code:

  1. Load the Endtest Chrome Extension ZIP file in the Chrome browser from the test.
  2. Enter your Endtest credentials in the Endtest Chrome Extension.
  3. Enter the starting URL for your test.
  4. Click on the Start Recording button.
# Load the Endtest Chrome Extension
options.add_extension("C:\test\endtest_chrome_extension.zip")

# Log in to the Endtest Chrome Extension
driver.find_element_by_id('userEmailLoginInput').send_keys("user@endtest.io")
driver.find_element_by_id('userPasswordLoginInput').send_keys("your-password")
driver.find_element_by_id('loginButton').click()

# Enter the starting URL for your test
driver.find_element_by_id('urlInput').send_keys("https://swit.io/auth/register")

# Click on the Start Recording button
driver.find_element_by_id('startRecordingButton').click()

When starting a test with our extension, the popup.html page from the Endtest Chrome Extension will be automatically loaded.

The URL for that page is dynamic and will be different for each test execution.

endtest migrate from selenium

We will need to access that page again at the end of the test.

And that's why we should fetch it and store it in a variable:

# Store URL for Endtest Chrome Extension in variable
endtest_chrome_extension_url = driver.current_url

This is how our code looks like after adding those steps:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Configure and start the WebDriver
chromedriver = "C:\test\chromedriver.exe"

desired = DesiredCapabilities.CHROME
desired['loggingPrefs'] = {'browser': 'ALL','driver':  'ALL'}

options = webdriver.ChromeOptions()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')
options.add_argument("--unhandledPromptBehavior=accept")

# Load the Endtest Chrome Extension
options.add_extension("C:\test\endtest_chrome_extension.zip")

driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=options,desired_capabilities=desired)

# Store URL for Endtest Chrome Extension in variable
endtest_chrome_extension_url = driver.current_url

# Log in to the Endtest Chrome Extension
driver.find_element_by_id('userEmailLoginInput').send_keys("user@endtest.io")
driver.find_element_by_id('userPasswordLoginInput').send_keys("your-password")
driver.find_element_by_id('loginButton').click()

# Enter the starting URL for your test
driver.find_element_by_id('urlInput').send_keys("https://swit.io/auth/register")

# Click on the Start Recording button
driver.find_element_by_id('startRecordingButton').click()

# Start the test
driver.get("https://swit.io/auth/register")

driver.find_element_by_id('firstName').send_keys("Saul")
driver.find_element_by_id('lastName').send_keys("Goodman")
driver.find_element_by_id('email').send_keys("saul@example.com")
driver.find_element_by_id('password').send_keys("RandomString@#987")

driver.find_element_by_id('signup').click()

# Quit the test
driver.quit()

In this current state, if we would execute that test, the Endtest Chrome Extension would record the steps but it would not save the test case.

That's why we need to add some steps at the end that will stop the recording and save the test case:

# Go to the Endtest Chrome Extension popup.html page
driver.get(endtest_chrome_extension_url)

# Click on the Stop Recording button
driver.find_element_by_id('stopRecordingButton').click()

# Write name for new test case
driver.find_element_by_id('testCaseNameInput').send_keys("Register Test Case")

# Select existing test suite or new test suite
driver.find_element_by_id('newTestSuiteRadio').click()

# Write name for new test suite
driver.find_element_by_id('newTestSuiteName').send_keys("Swit Test Suite")

# Click on Save button
driver.find_element_by_id('saveRecordingButton').click()

And after adding these final steps, this is how our code would look like:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import Select
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

# Configure and start the WebDriver
chromedriver = "C:\test\chromedriver.exe"

desired = DesiredCapabilities.CHROME
desired['loggingPrefs'] = {'browser': 'ALL','driver':  'ALL'}

options = webdriver.ChromeOptions()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')
options.add_argument("--unhandledPromptBehavior=accept")

# Load the Endtest Chrome Extension
options.add_extension("C:\test\endtest_chrome_extension.zip")

driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=options,desired_capabilities=desired)

# Store URL for Endtest Chrome Extension
endtest_chrome_extension_url = driver.current_url

# Log in to the Endtest Chrome Extension
driver.find_element_by_id('userEmailLoginInput').send_keys("user@endtest.io")
driver.find_element_by_id('userPasswordLoginInput').send_keys("your-password")
driver.find_element_by_id('loginButton').click()

# Enter the starting URL for your test
driver.find_element_by_id('urlInput').send_keys("https://swit.io/auth/register")

# Click on the Start Recording button
driver.find_element_by_id('startRecordingButton').click()

# Start the test
driver.get("https://swit.io/auth/register")

driver.find_element_by_id('firstName').send_keys("Saul")
driver.find_element_by_id('lastName').send_keys("Goodman")
driver.find_element_by_id('email').send_keys("saul@example.com")
driver.find_element_by_id('password').send_keys("RandomString@#987")

driver.find_element_by_id('signup').click()

# Go to the Endtest Chrome Extension popup.html page
driver.get(endtest_chrome_extension_url)

# Click on the Stop Recording button
driver.find_element_by_id('stopRecordingButton').click()

# Write name for new test case
driver.find_element_by_id('testCaseNameInput').send_keys("Register Test Case")

# Select existing test suite or new test suite
driver.find_element_by_id('newTestSuiteRadio').click()

# Write name for new test suite
driver.find_element_by_id('newTestSuiteName').send_keys("Swit Test Suite")

# Click on Save button
driver.find_element_by_id('saveRecordingButton').click()

# Quit the test
driver.quit()

After the execution is completed, we can find the recorded test in our Endtest account.

The following video shows what happens when we run that Python code:

← Export Web TestsHow to create Mobile Tests →
  • Introduction
  • How it works
  • Instructions
  • Example
© Endtest Inc.