-
Notifications
You must be signed in to change notification settings - Fork 0
App window classes
In order to make this framework follow a structure similar to Selenium's page object model, we will have classes that represent a particular window/section of our application:
All these classes must be in folder app_window_objects and extend the abstract class appwindowobject.py
This abstract class basically automates several processes:
- If in our constructor we provided a webdriver, we will just link our class attribute driver to that parameter driver. If we don't provide that, we will have to create that webdriver object and connect to appium with it. In order to do so:
It locates the JSON file in folder profile where we will extract the capabilities we need to provide for our webdriver: If the file current_test_profile.txt exists in folder tmp we will read its first line and try to look for a JSON file with that very same name in folder https://github.com/AntoData/appium-framework/tree/master/profiles. Otherwise, we will look for the file with the same name of our child class (the one we wrote that extends this one) in lowercase in folder https://github.com/AntoData/appium-framework/tree/master/profiles. For instance, if our class is called CalculatorMainApp, we will look for the file calculatormainapp.json in folder profiles.
-
We use that file to create an object called capabilities that will be a class attribute that we will use to create the webdrive we will need to interact with the app.
-
It loads all the ids, xpaths in an class attribute called id or xpath from a file with the extension ini with the same name as our child class (the one we wrote that extends this one) in lower case in the folder selector. So if our class is called CalculatorMainApp, we will look for the file calculatormainapp.ini and load all ids and xpaths from there.
-
Provides a class attribute called locators that provides methods to find elements using those ids, xpaths,... but with an implicit wait (which means if we use these, we will wait until the element is loaded/visible although there is a timeout).
-
Also these methods, provide a feature where we create a folder for our current webdriver-appium session in folder screenshots and every time we use one of these find methods, we will take a screenshot a save it as a png file in that session folder. Also we can use a method provided in that attribute locators to take screenshots at any point and save them in the same folder.
-
It provides a class attribute called video_recorder that using the class in desktopBrowserRecorder.py allows us to start recording our session to create a video and stop it using the methods provided for it. When creating an object that extends this class, the recording session will start by default
-
Method destroy: This method will stop our current recording session and quit our webdriver, in fact destroy our object
So we will have to create our custom made classes extending this abstract class, writing a constructor that calls to the constructor of its super class and writing methods that using our webdriver, methods in attribute selector... interact with our application. For instance, this class.
NOTE: Only the class for the first window will need the JSON file, for the other objects we must pass the driver as a parameter to the constructor