Creating Scripts

In this guide we will be using the following test scenario to demonstrate how to develop a simple test script:

  1. Open Wikipedia website
  2. Select English area
  3. Enter "selenium" in the search field
  4. Press "Search" button
  5. Validate that the page header shows the word "Selenium"

Basic Script

Oxygen provides a number of built-in objects (modules) for automation purposes. Because in our sample scenario we want to automate only browser interactions, we will use the web module. Refer to API Reference for a complete list of provided modules and methods.

  1. Open Wikipedia website.
    web.open('https://www.wikipedia.org/');

    open command accepts only one argument - web site URL. It will open the provided URL and return once the web-page has been fully loaded.

  2. Select English area.
    web.click('id=js-link-box-en');
  3. Enter "selenium" in the search field.

    web.type('name=search', 'selenium');

    type allows typed strings into input elements and accepts two arguments: a locator which will be used for finding the element and a string which will be typed into that element. See API Reference for a list of supported locators.

  4. Press "Search" (looking glass icon) button. This command will return once the web-page has been fully loaded.
    web.click('name=go');

    Similarly to other commands click accepts a locator argument. It will click on the provided element and block until the new page has been fully loaded.

  5. Validate that the page header shows the word "Selenium"
    web.assertText('id=firstHeading', 'Selenium');

    assertText asserts whether the element contains the specified text. This command will fail the test if element doesn't contain the text or wasn't found at all.  



Entire script:

web.open('https://www.wikipedia.org/');
web.click('id=js-link-box-en');
web.type('name=search', 'selenium');
web.click('name=go');
web.assertText('id=firstHeading', 'Selenium');

Now open a new script in the IDE and paste the above snippet into it. Save the file as wikipedia.js. In the dropdown menu select the browser you wish to run the script in and click Run.