0

I am just a beginner when it comes to python or coding in general. I'm trying to setup an automation framework using python-appium and the page object model. My question is, How do I include the setup method into my base page? When I call the method from my test script it says 'driver' is unresolved and throws an exception. I know I am just missing something simple but my google-fu has failed me and now I have posted here.

Here is my setup method:

def setUp(self):
    "Setup for the test"
    desired_caps = {}
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '6.0.1'
    desired_caps['deviceName'] = '05157df532e5e40e'
    # Returns abs path relative to this file and not cwd
    desired_caps['app'] = os.path.abspath(
        os.path.join(os.path.dirname(__file__), 
    '/Users/tyler/Desktop/Instasize_20172109_3.9.9_118_google.apk'))
    desired_caps['appPackage'] = 'com.jsdev.instasize'
    desired_caps['appActivity'] = '.activities.MainActivity'
    self.driver = webdriver.Remote('http://localhost:4723/wd/hub', 
    desired_caps)

I want to call this method to all my tests or a variation of it depending on the device being used. Here is how I am trying to call it from my base page:

def driverSetup(self):
    driverSetup = DriverBuilderAndroid(driver)
    driverSetup.setUp()

All of my import statements are present. Let me know if there is any other info you need. If you could refer to a python appium POM tutorial that would be much appreciated as well. This is my first post on stackoverflow.

1 Answers1

0

I created a separate python file called driverBuilder with my setup shown above. I then import it into each of my test files and call the method like this:

from DriverBuilder import DriverBuilder """<--class from DriverBuilder file"""

def test(self):
    driver = DriverBuilder.driver