-
Notifications
You must be signed in to change notification settings - Fork 0
/
Driver.py
44 lines (37 loc) · 1.69 KB
/
Driver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from appium import webdriver
import os
from pathlib import Path, PureWindowsPath, PurePosixPath
import platform
class AppiumDriverSetup(object):
driver = None
apkPathWindow = None
apkPathLinux = None
def apkPath(self):
try:
if platform.system() == "Windows":
print("Tests are being executed on WINDOW operating system")
PATH = PureWindowsPath(os.path.abspath(os.getcwd()))
apkPathWindow = str(PATH) + str("\YelloInterview.apk")
print('Window path is ::', apkPathWindow)
return apkPathWindow
if platform.system() == "Linux":
print("Tests are being executed on Linux operating system")
PATH = PurePosixPath(os.path.abspath(os.getcwd()))
apkPathLinux = str(PATH) + str("\YelloInterview.apk")
print('Linux path is ::', apkPathLinux)
return apkPathLinux
except IOError:
print("Unfortunately, apk file doesn't exist at that location")
def setUp(self):
desiredCapibilities = {}
desiredCapibilities['platformName'] = 'Android'
desiredCapibilities['platformVersion'] = '7.1.1'
desiredCapibilities['deviceName'] = 'Android Emulator'
desiredCapibilities['app'] = AppiumDriverSetup.apkPath(self)
desiredCapibilities['appPackage'] = 'com.recsolu.newton'
desiredCapibilities['appActivity'] = 'com.recsolu.newton.activities.LoginActivity'
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desiredCapibilities)
self.driver.implicitly_wait(30)
return self.driver
def tearDown(self):
self.driver.quit()