Selenium

Automated Web Testing and Monitoring with Selenium

  1. Add the Selenium IDE extension to your browser.

  2. Choose 'Create a new project' from the Selenium IDE home page as shown below.

  1. Click on the 'Start Recording' button in the top right corner.

  2. Enter the URL of the application that is to be tested, using the Selenium IDE. Here you can mimic end-user actions, which will then be converted into scripts.

  3. To stop recording, simply click on the 'Stop Recording' button.

  4. Now you can run the test you just recorded by clicking on the 'Run Current Test' button.

  • In the Selenium IDE, you are provided with the options to Rename, Duplicate, Delete, and Export test cases.

  • With the Selenium IDE, you have the ability to create fresh projects, access existing folders, and save your projects.

  • During the export process, you will be prompted to choose a language from a list of available options.

  • After exporting the file, you can proceed with creating the monitor.

There is a component of the Selenium suite called "Selenium Grid." Unlike Selenium, its main purpose is to run numerous tests on various browsers by utilizing hubs and nodes. The hub serves as the central point in the Selenium Grid, issuing commands to execute tests on different machines, which are referred to as Nodes.

Uncloud currently offers support for selenium monitoring using JavaScript mocha (.js/.ts), Python pytest, and side files. To enable selenium monitoring for JavaScript and Python files, the user must specify the selenium grid URL in the test file.

For taking screenshots, include the following lines of code in your JavaScript test file (The file name can be changed)

driver.takeScreenshot().then(
    function(image) {
        require('fs').writeFileSync('monitorings/screenshots/captured_image_1.png', image, 'base64');
    }
);

For taking screenshots, include the following lines of code in your Python test file (The file name can be changed)

self.driver.save_screenshot("monitorings/screenshots/screenshot.png")

For taking a screen recording, include the following lines of code in your JavaScript test file

afterEach(async function () {
    const sessionInfo = await driver.session_
    addContext(this, {
        title: 'sessionId',
        value: sessionInfo.id_
    });
    await driver.quit();
});

For taking a screen recording, include the following lines of code in your Python test file

json_metadata['sessionId'] = self.driver.session_id

To include multiple tests in a single JavaScript file, create each test as different "it" functions

describe("test_name", function () {
    it("Test_1", async function () {
        // Add your test script here
    });
    
    it("Test_1", async function () {
        // Add your test script here
    });
});

To include multiple tests inside a single Python file, create each test as different functions

def test_1(self, json_metadata):
    // Add your test script here
    
def test_2(self, json_metadata):
    // Add your test script here

Last updated