1

I am curious to know that while implementing automation framework using selenium webdriver, why cant we use excel as an object repository and why everyone is using PageObject or property file to store all locators. I am thinking like if we use excel to save all element locator by pagewise then it is easy to keep all locators at one place/one excel and if required we can easily change the locators-path too.

Though i am looking for suggestion before going ahead and implementing the same and if there is any disadvantage to using excel.

3
  • I wonder how it works performance wise. What happens if you have test running parallel and trying to use the same file. I mean you are adding another layer here. I keep my locators in 1 package and for each view I use a class. This also means I don't have to open an excel file, if I wanna edit something. Jul 14, 2015 at 9:10
  • I am a newbie and implementing automation framework for the first time and haven't thought from performance perspective. Also i am just thinking to read an excel for the first time and storing all data in arraylist so that data can be accessed multiple times without reopening excel. But as you said i need to check its impact on performance. Thanks a lot.
    – Ajay Pande
    Jul 14, 2015 at 10:31
  • everyone is using PageObject or property file - I dont think everyone uses it. We dont. Btw didnt understand why the same thing you are doing in excel cant be achieved in a property file. Personally we use xml files to store locators pagewise.
    – Shamik
    Jul 14, 2015 at 11:50

1 Answer 1

0

Personally i just create a locators package and keep individual page locator files in there and import them as needed. It's a matter of preference how/where you store them really.

i guess this technique does go against the page object model like you said. Not sure why you would want to store them in an excel sheet to be honest though. its just going to be an extra step opening and reading the excel file.

Just to expand on that, the locators contains locators like this:

    public static final By adminLoginPageForm() {return By.id("login-form");}
    public static final By adminLoginPageUserName() {return By.id("uname");}
    public static final By adminLoginPageUserPass() {return By.id("pass");}
    public static final By adminLoginPageLoginButton() {return By.id("loginBtn");}

And then they are referenced in the page classes like:

    import locators.adminPageLocators.*;
    WebElement adminLoginPageLoginButton= getDriver().findElement(adminLoginPageLoginButton());
    adminLoginPageLoginButton.click();
1
  • Thanks Cathal for your reply and explanation. We are planning to create a test script which can be daily run by manual testers (who don't have knowledge of automation framework and coding). We will teach them how to capture page element in case page object gets changed, so he only needs to open an excel, update the locator and re-run the test.
    – Ajay Pande
    Jul 14, 2015 at 10:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.