Object Repository
This allows us to store configurations specific to the application we will test and manage them centrally, independent of the environment. You can store locator information such as Xpath or CSS from or endpoint addresses etc. in the object repository.
Let's explain with an example; consider a webpage where there is an Xpath locator for a button named "Save," and this locator is used by multiple tests. If there is any change in this locator, all tests that use it would need to be updated. However, if we define this locator within the object repository, we can quickly resolve it by just updating the repository definition.
Repo Groups
Repositories are located under the repo groups in a directory named object_repository
. Repo groups logically organize repositories and provide clean access.

Repos
Repositories store objects in key-value
pairs and in JSON format. Below is an example repo for the login page:

Generate New Repo
use sente new
command
sente new


Generate New Repo Group and New Repo
use sente new
command
sente new


Call Repo Object From Test
use repo.<repo_group>.<repo_name>.key
module.exports= {
username_input: `//input[@id='forms_login_dataform_username']`,
password_input: `//input[@id='forms_login_dataform_password']`,
popup:{
serverManager:{
add_button: `//button[@id='popups_manage_servers_popup_common_buttons_action_add']`,
delete_button: `//button[@id='popups_manage_servers_popup_common_buttons_action_remove']`,
}
}
};
/* TEST FLOW
*************/
test = async () => {
let password_input = repo.ui.login.password_input;
let add_button = repo.ui.login.popup.serverManager.add_button;
}
Change Object Dynamically (overrideRepo)
If a part of your repo object changes during the test run, you can use the overrideRepo
method to adapt to this change.
Let's explain with an example; Assume there is a list box in a web GUI where we select colors. XPaths are as follows. Instead of writing an XPath for each, we can store the common part and change the color part during testing.
option1: `//p-dropdownitem//li//*[text()='RED']`
option2: `//p-dropdownitem//li//*[text()='BLUE']`
option3: `//p-dropdownitem//li//*[text()='YELLOW']`
option4: `//p-dropdownitem//li//*[text()='GREEN']`
Add a key named color_options
to the object repository by using the keyword <sente>
in place of the COLOR part.
module.exports= {
color_options: `//p-dropdownitem//li//*[text()='<sente>']`
};
To call this repo key from the test, we will use the overrideRepo method. This method is used as follows:
overrideRepo(<repo_key>, <value>);
This method will replace the <sente>
placeholder in the repo key with the value we pass as <value>
.
const { sente } = require('#libraries');
const { overrideRepo } = sente;
/* TEST FLOW
*************/
test = async () => {
let option_red = overrideRepo(repo.ui.login.color_options, 'RED')
}
Custom Keyword
Note that using the <sente>
keyword is not mandatory. <sente>
is the default keyword. For example, let's use XXYY
as a keyword to generate our repo key as follows:
module.exports= {
color_options: `//p-dropdownitem//li//*[text()='XXYY']`
};
To call this repo key from the test, we will use the overrideRepo method. This method is used as follows:
overrideRepo(<repo_key>, <value>, <custom_keyword>);
This method will replace the <XXYY>
placeholder in the repo key with the value we pass as <value>
.
/* TEST FLOW
*************/
test = async () => {
let option_red = overrideRepo(repo.ui.login.color_options, 'RED', 'XXYY')
}
Last updated