Page Object Framework Implementation using web driver.
Mon Mar 11, 2013 5:41 pm
Hi Guys,
I heard lot about the page object using in automation these days and concept is totally new to me. I was curious how to implement and benefits of page object. I started working on it and implement the concept practically to see its complexity, benefits and maintenance of scripts. I created a dummy framework on Google site with implementation of page object concepts. If you want to learn, get ready for roller coaster path of learning. Get, Set, GO..!!
Note: This framework is developed on JAVA using eclipse. For this you have an understanding of core java concepts like classes, packages, access variables scope, selenium web driver API. If you are not having any programming background or just at beginner level; I recommended don’t go for it. Before stating into just read the following links:
1. https://www.youtube.com/watch?v=xaWLIBKAQps (How to setup eclipse)
2. http://blog.activelylazy.co.uk/2011/07/09/page-objects-in-selenium-2-0/ (read this first. Simple one)
3. http://selenium-tutorial.blogspot.in/2012/06/webdriver-page-objects-pattern.html (Cumulative tutorial. Read as per your interest and curiosity.)
Framework Overview:
This is not a full functional framework, don’t expect much from it. It’s just a draft which you can use in your framework, as per your requirement. I created it during learning about page object and it’s an effort of 4-5 days. Don’t follow it blindly use your own judgments and experience. It’s focus only on page object implementation. You can call it module driven framework, if you want to name it.
Note: Before Start reading further, download the project on your machine to look side by side
Download from here: http://www.mediafire.com/?lfodfvfgzu2fvhc
Doc download : http://www.mediafire.com/view/?6u74h9alcgzb4vf
This download may not work after 15 download due to free user limitation. please upload the framework u downloaded, from your account and share the URL so that everybody can download it.
It contains the following directory structure
1. SRC(root directory under this all packages and classes defined)
2. GoogleTestingFramework(All code related to linking and execution of test suite and test cases.)
3. Results(All results file goes into this directory.)
4. TestData(If any test data will be use, comes here)
GoogleTestingFramework consist of driver script which invoke the whole process. The settings file which have all customize/flexibility option. The global variables which is used throughout the execution, is at project level. These are available for every test case.
Under this one directory define named Library, which contain common Function file and customize Utilities functions. It’s just a functionality of your framework.
Under this one directory define named Object Repository. This is directory where page objects concepts start. For each page in your AUT, one corresponding class file will define here.
For Ex: If your application has 15 different pages in a complete flow. There will be 15 class file with page name contains all unique object present on page with all operations defined in form of functions. These functions uses the object defines in class file.
Under this one directory define named Test suite, which contains all test cases you prepared for testing. The test case uses the page object file with some assertions defined. So your verification points defined in separate file and traversing operation in page object file. If your UI changes then you have to changes your page object file and your test flow/cases remain same. By this way we separate the UI things with flow implementation. That’s the objective of page object.
Results And Test Data don’t need any explanation.
In Eclipse, the structure will look like this:
The code contains comment which is self-explanatory. By this way you can implement the page object.
Action items to run code.
1. Add the project to eclipse and make sure no error will be there. If error will appear try to resolve it may be some jar is missing in your eclipse. On my end it’s working and tested.
2. I removed all the jar files due to heavy size. Copy all selenium jar into lib folder of project to remove all error. View the first tutorial to setup eclipse for more clarity.
3. Change the user Id and password as per your account in global variables file.
4. This code is tested on Firefox. Not sure about other browser; it may not work on others.
5. Execute the driver script as Java application.
Hope, This will help to create more robust framework implemetation. Share your thoughts to improve this stuff, If any.
Regards
ADVISER
I heard lot about the page object using in automation these days and concept is totally new to me. I was curious how to implement and benefits of page object. I started working on it and implement the concept practically to see its complexity, benefits and maintenance of scripts. I created a dummy framework on Google site with implementation of page object concepts. If you want to learn, get ready for roller coaster path of learning. Get, Set, GO..!!
Note: This framework is developed on JAVA using eclipse. For this you have an understanding of core java concepts like classes, packages, access variables scope, selenium web driver API. If you are not having any programming background or just at beginner level; I recommended don’t go for it. Before stating into just read the following links:
1. https://www.youtube.com/watch?v=xaWLIBKAQps (How to setup eclipse)
2. http://blog.activelylazy.co.uk/2011/07/09/page-objects-in-selenium-2-0/ (read this first. Simple one)
3. http://selenium-tutorial.blogspot.in/2012/06/webdriver-page-objects-pattern.html (Cumulative tutorial. Read as per your interest and curiosity.)
Framework Overview:
This is not a full functional framework, don’t expect much from it. It’s just a draft which you can use in your framework, as per your requirement. I created it during learning about page object and it’s an effort of 4-5 days. Don’t follow it blindly use your own judgments and experience. It’s focus only on page object implementation. You can call it module driven framework, if you want to name it.
Note: Before Start reading further, download the project on your machine to look side by side
Download from here: http://www.mediafire.com/?lfodfvfgzu2fvhc
Doc download : http://www.mediafire.com/view/?6u74h9alcgzb4vf
This download may not work after 15 download due to free user limitation. please upload the framework u downloaded, from your account and share the URL so that everybody can download it.
It contains the following directory structure
1. SRC(root directory under this all packages and classes defined)
2. GoogleTestingFramework(All code related to linking and execution of test suite and test cases.)
3. Results(All results file goes into this directory.)
4. TestData(If any test data will be use, comes here)
GoogleTestingFramework consist of driver script which invoke the whole process. The settings file which have all customize/flexibility option. The global variables which is used throughout the execution, is at project level. These are available for every test case.
Under this one directory define named Library, which contain common Function file and customize Utilities functions. It’s just a functionality of your framework.
Under this one directory define named Object Repository. This is directory where page objects concepts start. For each page in your AUT, one corresponding class file will define here.
For Ex: If your application has 15 different pages in a complete flow. There will be 15 class file with page name contains all unique object present on page with all operations defined in form of functions. These functions uses the object defines in class file.
Under this one directory define named Test suite, which contains all test cases you prepared for testing. The test case uses the page object file with some assertions defined. So your verification points defined in separate file and traversing operation in page object file. If your UI changes then you have to changes your page object file and your test flow/cases remain same. By this way we separate the UI things with flow implementation. That’s the objective of page object.
Results And Test Data don’t need any explanation.
In Eclipse, the structure will look like this:
The code contains comment which is self-explanatory. By this way you can implement the page object.
Action items to run code.
1. Add the project to eclipse and make sure no error will be there. If error will appear try to resolve it may be some jar is missing in your eclipse. On my end it’s working and tested.
2. I removed all the jar files due to heavy size. Copy all selenium jar into lib folder of project to remove all error. View the first tutorial to setup eclipse for more clarity.
3. Change the user Id and password as per your account in global variables file.
4. This code is tested on Firefox. Not sure about other browser; it may not work on others.
5. Execute the driver script as Java application.
Hope, This will help to create more robust framework implemetation. Share your thoughts to improve this stuff, If any.
Regards
ADVISER
- 10 steps to set up Selenium Automation Hybrid Framework with implementing Testng, Log4j, Page Object Model, Data Driven, Modular Driven, Exceptions
- How to use WebDriverEventListener in Page Object Model design Pattern with Page Factory
- Page Object Pattern/Model using Page Factory
- Page Object Model
- Joining arguments o locate a page object
Permissions in this forum:
You cannot reply to topics in this forum
|
|