8000 ci: Take screen record as evidence (#481) · sysbender/python-client@778ad60 · GitHub
[go: up one dir, main page]

Skip to content

Commit 778ad60

Browse files
authored
ci: Take screen record as evidence (appium#481)
* Take screen record for android * Take screen record for iOS * Save screen record for iOS
1 parent e8b4ab1 commit 778ad60

File tree

4 files changed

+21
-4
lines changed

4 files changed

+21
-4
lines changed

ci-jobs/functional/run_ios_test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ jobs:
1414
python -m pytest ${{ parameters.testFiles}} ${{ parameters.pytestOpt }}
1515
displayName: Run iOS functional tests
1616
- template: ./publish_test_result.yml
17+
- template: ./save_appium_log.yml
18+
parameters:
19+
name: ${{ parameters.name }}

ci-jobs/functional/save_appium_log.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ steps:
99
condition: succeededOrFailed()
1010
inputs:
1111
contents:
12-
'**/test_*.png'
12+
'**/test_*.mp4'
1313
targetFolder: $(Build.ArtifactStagingDirectory)
1414
- task: PublishBuildArtifacts@1
1515
condition: succeededOrFailed()

test/functional/android/helper/test_helper.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515

16+
import base64
1617
import os
1718
import unittest
1819

@@ -57,10 +58,13 @@ class BaseTestCase(unittest.TestCase):
5758
def setUp(self):
5859
desired_caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk.zip')
5960
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
61+
if is_ci():
62+
self.driver.start_recording_screen()
6063

6164
def tearDown(self):
6265
if is_ci():
63-
# Take the screenshot to investigate when tests failed only on CI
64-
img_path = os.path.join(os.getcwd(), self._testMethodName + '.png')
65-
self.driver.get_screenshot_as_file(img_path)
66+
payload = self.driver.stop_recording_screen()
67+
video_path = os.path.join(os.getcwd(), self._testMethodName + '.mp4')
68+
with open(video_path, "wb") as fd:
69+
fd.write(base64.b64decode(payload))
6670
self.driver.quit()

test/functional/ios/helper/test_helper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
# limitations under the License.
1414

1515

16+
import base64
17+
import os
1618
import unittest
1719

1820
from appium import webdriver
21+
from test.functional.test_helper import is_ci
1922

2023
from . import desired_capabilities
2124

@@ -25,6 +28,13 @@ class BaseTestCase(unittest.TestCase):
2528
def setUp(self):
2629
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
2730
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
31+
if is_ci():
32+
self.driver.start_recording_screen()
2833

2934
def tearDown(self):
35+
if is_ci():
36+
payload = self.driver.stop_recording_screen()
37+
video_path = os.path.join(os.getcwd(), self._testMethodName + '.mp4')
38+
with open(video_path, "wb") as fd:
39+
fd.write(base64.b64decode(payload))
3040
self.driver.quit()

0 commit comments

Comments
 (0)
0