This selector was used twice in just one simplest test case. Imagine that you have 500 test cases, I'm pretty sure you will have hundreds of dups. In order to avoid it, we are going to implement a Software Design Pattern which is called Page Object Model.
Page Object Model - is a very popular design pattern used that we will use in building our automation frameworks. In a few words: it's a way to structure code. In a previous article you saw us running a basic automation test of the instagram website. It works fine, but looks a little ugly and some code is duplicated.
Based on a previous article, your framework should look like this:
- node_modules (all of our modules/packages/libraries live there)
- specs (all of tests live there)
- package-lock.json (history of your npm updates - not used much)
- package.json (basic information about your framework with list of modules/packages/libraries we've installed)
- wdio.cong.js (actual configurations file where we specify base information like: timeouts, baseUrl etc)
Now we need to add a new folder page_objects folder and login folder inside of it: