Object Locator parameterization

Hi ,

In RF , here we are hardcoding locators , is there any way we can parameterize and read them from any file so that in case of any change we need not to change in all files.

Thanks,
Neha Dua

I use config file for that:

MAIN_PAGE = {
    "Input username" : "xpath://*[@id='username'],
    "login button" : "xpath://button[@id='login']"
}

If that file is called main_page_pom.py you can reference it in your robot file:

*** Settings ***
Variables    main_page_pom.py

*** Tasks ***
Login user
    Input Text    ${MAIN_PAGE}[input username]
    Click button    ${MAIN_PAGE}[login button]

Regards,
Markus

1 Like

you can use an {} and string format