# Creating a Web Test

## Creating Scripts <a href="#creating-scripts" id="creating-scripts"></a>

For Oxygen IDE download instructions - please refer to the [Download Page](https://docs.oxygenhq.org/download-installation-start/download-and-installation/download-oxygen-ide).

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 <a href="#basic-script" id="basic-script"></a>

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.

   ```javascript
   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.

   ```javascript
   web.click('id=js-link-box-en');
   ```
3. Enter "selenium" in the search field.

   ```javascript
   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.

   ```javascript
   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"

   ```javascript
   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:

```javascript
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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.oxygenhq.org/download-installation-start/start-working-with-oxygen/getting-started-web/creating-web-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
