File tree Expand file tree Collapse file tree 5 files changed +54
-9
lines changed Expand file tree Collapse file tree 5 files changed +54
-9
lines changed Original file line number Diff line number Diff line change 1
1
default :
2
+ DEBUG : True
2
3
APPIUM_SERVER : " http://localhost:4723/wd/hub"
3
4
4
5
stage :
5
- APPIUM_SERVER : " http://stage:4723/wd/hub"
6
- ANDROID_CAPS :
6
+ DEBUG : True
7
+ APPIUM_SERVER : " http://stage-address:4723/wd/hub"
8
+ ANDROID :
7
9
platformName : " Android"
8
10
deviceName : " emulator"
9
- app : " /path/to/app.apk"
11
+ app : " "
12
+ platformVersion : " 15"
13
+ automationName : " uiautomator2"
10
14
11
15
prod :
12
- APPIUM_SERVER : " http://prod:4723/wd/hub"
13
- IOS_CAPS :
16
+ DEBUG : True
17
+ APPIUM_SERVER : " http://prod-adress:4723/wd/hub"
18
+ IOS :
14
19
platformName : " iOS"
15
20
deviceName : " iPhone 14"
16
21
bundleId : " com.example.app"
22
+ automationName : " XCUITest"
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ dynaconf = "^3.2.10"
18
18
requests = " ^2.31"
19
19
pytest-asyncio = " ^0.24.0"
20
20
pytest-html = " ^4.1.1"
21
+ Appium-Python-Client = " ^4.5.1"
21
22
22
23
[tool .poetry .dev-dependencies ]
23
24
ruff = " ^0.6.8"
Original file line number Diff line number Diff line change
1
+ from pathlib import Path
2
+
3
+ from config import settings
4
+
5
+
6
+ class AndroidCaps :
7
+ @staticmethod
8
+ def get_caps ():
9
+ """Generate and return Android capabilities, with adding dynamic 'app' path."""
10
+ caps = settings .ANDROID .to_dict ()
11
+
12
+ if not caps :
13
+ raise ValueError ("❌ ANDROID capabilities not found in settings.yaml" )
14
+
15
+ caps ["app" ] = str (Path (__file__ ).resolve ().parents [2 ] / "data/apps/app.apk" )
16
+
17
+ return caps
Original file line number Diff line number Diff line change
1
+ from appium import webdriver
2
+
3
+ from config import settings
4
+ from src .drivers .android_driver import AndroidCaps
5
+
6
+
1
7
class Driver :
2
-
3
- @staticmethod
4
- def get_driver (platform : str ):
5
- """Get driver by platform"""
8
+ @staticmethod
9
+ def get_driver (platform : str ):
10
+ """Get driver by platform, uses appropriate capabilities for Android or iOS."""
11
+ if platform .lower () == "android" :
12
+ caps = AndroidCaps .get_caps ()
13
+ else :
14
+ caps = settings .iOS .to_dict ()
15
+
16
+ driver = webdriver .Remote (settings .APPIUM_SERVER , caps )
17
+ return driver
Original file line number Diff line number Diff line change
1
+ from appium .webdriver import webdriver
2
+
3
+ from config import settings
4
+
5
+
6
+ class iOSDriver :
7
+ @staticmethod
8
+ def get_driver (platform : str ):
9
+ return webdriver .Remote (settings .APPIUM_SERVER , caps )
You can’t perform that action at this time.
0 commit comments