Skip to content

Commit 1992cf4

Browse files
added swipe until wrapper
1 parent 06245d2 commit 1992cf4

5 files changed

Lines changed: 20 additions & 6 deletions

File tree

readme.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ budtmo/docker-android-x86-11.0
5151
## Test Report
5252
| Type | Command |
5353
| -------------- | --------- |
54-
| HTML Report | `python3 -m pytest src/spec/*.py --html=report/report.html` |
55-
| JSON Report | `python3 -m pytest src/spec/*.py --json=report/json/report.json` |
56-
| Allure Report | `python3 -m pytest src/spec/* --alluredir=report` |
54+
| HTML Report | `python3 -m pytest src/spec/android/*.py --html-report=report/report.html --app=android` |
55+
| JSON Report | `python3 -m pytest src/spec/android/*.py --json=report/json/report.json --app=android` |
56+
| Allure Report | `python3 -m pytest src/spec/android/* --alluredir=report --app=android` |
5757

5858
- Download allure commandline
5959
https://github.com/allure-framework/allure2/releases
@@ -100,5 +100,6 @@ allure serve report/
100100
| | `App.assert_size(self, locator, 'equal to 1')` |
101101
| | `App.assert_size(self, locator, '== 1')` |
102102
| assert_boolean | `App.assert_boolean(True, True)` |
103+
| swipe_until | `App.swipe_until(self, locator, start_x=144, start_y=434)` |
103104

104105
![](https://i.imgur.com/5vjklOb.png)

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
Appium-Python-Client~=1.0.2
22
selenium~=3.141.0
3-
pytest~=6.0.1
3+
pytest~=6.1.1
44
allure-pytest
55
pytest-parallel
66
pytest-xdist
77
pytest-rerunfailures
88
pytest-sugar
99
pytest-json
10-
pymysql~=0.10.0
10+
pymysql~=0.10.1
1111
sshtunnel~=0.1.5
1212
requests~=2.24.0
1313
invoke~=1.4.1
1414
python-dotenv
15-
pytest-html-reporter~=0.2.2
15+
pytest-html-reporter~=0.2.3

src/helpers/app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,17 @@ def assert_size(self, locator, param):
238238
elif case in ['equal to', '==']:
239239
assert App.elements(self, locator).__len__() == value
240240

241+
def swipe_until(self, locator, start_x=100, start_y=200, end_x=0, end_y=0, duration=0, count=10):
242+
self.driver.implicitly_wait(0.5) # waits half a second
243+
for i in range(count):
244+
try:
245+
self.driver.find_element(*locator).is_displayed()
246+
break
247+
except Exception as e:
248+
self.driver.swipe(start_x, start_y, end_x, end_y, duration)
249+
250+
self.driver.implicitly_wait(5) # waits 5 seconds
251+
241252
def assert_equal(self, actual, expected, n=5):
242253
x = iter(CustomCall())
243254
while n > 1:

src/screens/android/home_screen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class HomeScreen(Driver):
1010
formsMenu = (MobileBy.ACCESSIBILITY_ID, "Forms")
1111
homeMenu = (MobileBy.ACCESSIBILITY_ID, "Home")
1212
swipeMenu = (MobileBy.ACCESSIBILITY_ID, "Swipe")
13+
supportLink = (MobileBy.XPATH, '//android.widget.ScrollView[@content-desc="Home-screen"]/android.view.ViewGroup/android.view.ViewGroup[2]/android.widget.TextView[3]')
1314

1415
# swipeMenu = {'ANDROID': (MobileBy.ACCESSIBILITY_ID, "Swipe"),'IOS': (MobileBy.ACCESSIBILITY_ID, "Swipe")}
1516

src/spec/android/home_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def test_home_1(self):
1515
App.element(self, HomeScreen.loginMenu)
1616
App.element(self, HomeScreen.formsMenu)
1717
App.element(self, HomeScreen.swipeMenu)
18+
App.swipe_until(self, HomeScreen.supportLink, start_x=144, start_y=434)
1819
# App.assert_text(self, HomeLocators.loginMenu, 'Leads')
1920

2021
@pytest.mark.home

0 commit comments

Comments
 (0)