Sample Project - Web Test
A project should include 3 core files:
oxygen.conf.js, which includes the project configuration, this file contains the tools for the project such as which modules to use, creating suites to run multiple scripts, reporting type, etc.
oxygen.env.js, which includes the environments, different URLs, usernames, connection string for each environment, which can be later used by selecting the environment inside oxygen settings.
oxygen.po.js, which includes all the page objects, locators, functions, etc.

Simple web test example from scratch

Let's start by creating a folder and inside it creating the oxygen.env.js and defining our environments
1
module.exports = {
2
3
TEST: {
4
url: 'https://test.wikipedia.org',
5
db_con_string: 'Driver={SQL Server};Server=DESKTOP\\SQLEXPRESS;Database=test;'
6
username: 'test.user',
7
password: 'test123'
8
},
9
10
PROD: {
11
url: 'https://wikipedia.org',
12
db_con_string: 'Driver={SQL Server};Server=DESKTOP\\SQLEXPRESS;Database=prod;',
13
username: 'username',
14
password: 'password'
15
},
16
17
}
Copied!
Now let's create the oxygen.po.js file
1
module.exports = {
2
3
searchPage: {
4
searchInput: 'id=searchInput',
5
searchButton: '//button[@type="submit"]'
6
},
7
8
search: (item) => {
9
web.type(po.searchPage.searchInput, item)
10
web.click(po.searchPage.searchButton)
11
}
12
13
}
Copied!
Finally let's create the oxygen.conf.js file
1
module.exports = {
2
3
suites: [{
4
name: 'End to End tests',
5
cases: [
6
{ path: './Scripts/01. ' },
7
{ path: './Scripts/02. ' },
8
{ path: './Scripts/03. ' },
9
]
10
}],
11
12
modules: ['web', 'log', 'assert'],
13
14
reporting: {
15
reporters: ['html', 'json']
16
},
17
18
}
Copied!
And now let's create a folder with our test scripts, our first test will be searching for Selenium in Wikipedia
Don't forget to choose an environment
1
web.transaction('01. Initialize')
2
web.init()
3
4
web.transaction('02. Open Wikipedia Main Page')
5
web.open(env.url)
6
7
web.transaction('03. Seach For Selenium')
8
po.search('Selenium')
9
10
web.transaction('04. Assert Results')
11
web.assertTextPresent('Selenium')
Copied!
The following repository is provided as a sample project.
Last modified 7mo ago