Driver Class

We need to create the Driver.py file under the base package and create a class as Driver and then create a method in that class as getDriverMethod().

Under this method we need to define desired capabilities and return the driver object.

DriverClass.py

from appium import webdriver
from AppiumFrameWork.configurationfiles import DeviceConfig as dc


class Driver:

def getDriverMethod(self):
        desired_caps = {}
        desired_caps['platformName'] = dc.pName
        desired_caps['platformVersion'] = dc.platformVersion
        desired_caps['deviceName'] = 'Pixel'
        desired_caps['automationName'] = 'uiautomator2'
        desired_caps['app'] = (dc.appPath)
        desired_caps['appPackage'] = dc.appPackage
        desired_caps['appActivity'] = dc.appActivity

        driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", desired_caps)

        return driver




Device Config

Create a DeviceConfig.py class under configurationfiles package. In this class we need to create variables and assign the data which we can use in other classes this makes it more reusable.

In the similar way we will define all the variables and assign the values in the device config file.


DeviceConfig.py

platformVersion = '11'
pName = "Android"
appPackage = "com.skill2lead.appiumdemo"
appActivity = "com.skill2lead.appiumdemo.MainActivity"
appPath = "/Users/admin/Documents/Skill2Lead/Appium_Demo_App/Android/Android_Appium_Demo.apk"