';
72 | },
73 | adjustImageSize: function (event) {
74 | var overImage = this.$(event.target);
75 | overImage.width(overImage.width());
76 | },
77 | onRender: function () {
78 | const diffType = settings.get('diffType');
79 | this.$('[name="screen-diff-type"][value="' + diffType + '"]').prop('checked', true);
80 | if (diffType === 'overlay') {
81 | this.$('.screen-diff__image-over img').on('load', this.adjustImageSize.bind(this));
82 | }
83 | },
84 | onOverlayMove: function (event) {
85 | var pageX = event.pageX;
86 | var containerScroll = this.$('.screen-diff__container').scrollLeft();
87 | var elementX = event.currentTarget.getBoundingClientRect().left;
88 | var delta = pageX - elementX + containerScroll;
89 | this.$('.screen-diff__image-over').width(delta);
90 | },
91 | onDiffTypeChange: function (event) {
92 | settings.save('diffType', event.target.value);
93 | this.render();
94 | }
95 | });
96 | allure.api.addTestResultBlock(ScreenDiffView, {position: 'before'});
97 | })();
98 |
--------------------------------------------------------------------------------
/report/plugins/screen-diff/styles.css:
--------------------------------------------------------------------------------
1 | .screen-diff__switchers {
2 | margin-bottom: 1em;
3 | }
4 |
5 | .screen-diff__switchers label + label {
6 | margin-left: 1em;
7 | }
8 |
9 | .screen-diff__overlay {
10 | position: relative;
11 | cursor: col-resize;
12 | }
13 |
14 | .screen-diff__container {
15 | overflow-x: auto;
16 | }
17 |
18 | .screen-diff__image-over {
19 | top: 0;
20 | left: 0;
21 | bottom: 0;
22 | background: #fff;
23 | position: absolute;
24 | overflow: hidden;
25 | box-shadow: 2px 0 1px -1px #aaa;
26 | }
27 |
--------------------------------------------------------------------------------
/report/widgets/behaviors.json:
--------------------------------------------------------------------------------
1 | {
2 | "total" : 2,
3 | "items" : [ {
4 | "uid" : "3fdb9c22411d31bf190d07c864a52ab7",
5 | "name" : "百度feature",
6 | "statistic" : {
7 | "failed" : 1,
8 | "broken" : 0,
9 | "skipped" : 0,
10 | "passed" : 0,
11 | "unknown" : 0,
12 | "total" : 1
13 | }
14 | }, {
15 | "uid" : "70ed4f59de4a8a5ad0e39475526a5002",
16 | "name" : "8891中古车",
17 | "statistic" : {
18 | "failed" : 0,
19 | "broken" : 0,
20 | "skipped" : 0,
21 | "passed" : 1,
22 | "unknown" : 0,
23 | "total" : 1
24 | }
25 | } ]
26 | }
--------------------------------------------------------------------------------
/report/widgets/categories-trend.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "data" : {
3 | "Product defects" : 1
4 | }
5 | } ]
--------------------------------------------------------------------------------
/report/widgets/categories.json:
--------------------------------------------------------------------------------
1 | {
2 | "total" : 1,
3 | "items" : [ {
4 | "uid" : "8fb3a91ba5aaf9de24cc8a92edc82b5d",
5 | "name" : "Product defects",
6 | "statistic" : {
7 | "failed" : 1,
8 | "broken" : 0,
9 | "skipped" : 0,
10 | "passed" : 0,
11 | "unknown" : 0,
12 | "total" : 1
13 | }
14 | } ]
15 | }
--------------------------------------------------------------------------------
/report/widgets/duration-trend.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "data" : {
3 | "duration" : 1335032
4 | }
5 | } ]
--------------------------------------------------------------------------------
/report/widgets/duration.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "uid" : "8f4da5e50bcafd58",
3 | "name" : "test_two",
4 | "time" : {
5 | "start" : 1562124266533,
6 | "stop" : 1562124267252,
7 | "duration" : 719
8 | },
9 | "status" : "failed",
10 | "severity" : "normal"
11 | }, {
12 | "uid" : "170a3035cde28e7b",
13 | "name" : "test_one",
14 | "time" : {
15 | "start" : 1562125512194,
16 | "stop" : 1562125517470,
17 | "duration" : 5276
18 | },
19 | "status" : "passed",
20 | "severity" : "normal"
21 | }, {
22 | "uid" : "627d1a6748cffb3a",
23 | "name" : "test_login",
24 | "time" : {
25 | "start" : 1562125597087,
26 | "stop" : 1562125601565,
27 | "duration" : 4478
28 | },
29 | "status" : "passed",
30 | "severity" : "normal"
31 | } ]
--------------------------------------------------------------------------------
/report/widgets/environment.json:
--------------------------------------------------------------------------------
1 | [ ]
--------------------------------------------------------------------------------
/report/widgets/executors.json:
--------------------------------------------------------------------------------
1 | [ ]
--------------------------------------------------------------------------------
/report/widgets/history-trend.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "data" : {
3 | "failed" : 1,
4 | "broken" : 0,
5 | "skipped" : 0,
6 | "passed" : 2,
7 | "unknown" : 0,
8 | "total" : 3
9 | }
10 | } ]
--------------------------------------------------------------------------------
/report/widgets/launch.json:
--------------------------------------------------------------------------------
1 | [ ]
--------------------------------------------------------------------------------
/report/widgets/retry-trend.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "data" : {
3 | "run" : 3,
4 | "retry" : 12
5 | }
6 | } ]
--------------------------------------------------------------------------------
/report/widgets/severity.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "uid" : "170a3035cde28e7b",
3 | "name" : "test_one",
4 | "time" : {
5 | "start" : 1562125512194,
6 | "stop" : 1562125517470,
7 | "duration" : 5276
8 | },
9 | "status" : "passed",
10 | "severity" : "normal"
11 | }, {
12 | "uid" : "627d1a6748cffb3a",
13 | "name" : "test_login",
14 | "time" : {
15 | "start" : 1562125597087,
16 | "stop" : 1562125601565,
17 | "duration" : 4478
18 | },
19 | "status" : "passed",
20 | "severity" : "normal"
21 | }, {
22 | "uid" : "8f4da5e50bcafd58",
23 | "name" : "test_two",
24 | "time" : {
25 | "start" : 1562124266533,
26 | "stop" : 1562124267252,
27 | "duration" : 719
28 | },
29 | "status" : "failed",
30 | "severity" : "normal"
31 | } ]
--------------------------------------------------------------------------------
/report/widgets/status-chart.json:
--------------------------------------------------------------------------------
1 | [ {
2 | "uid" : "8f4da5e50bcafd58",
3 | "name" : "test_two",
4 | "time" : {
5 | "start" : 1562124266533,
6 | "stop" : 1562124267252,
7 | "duration" : 719
8 | },
9 | "status" : "failed",
10 | "severity" : "normal"
11 | }, {
12 | "uid" : "170a3035cde28e7b",
13 | "name" : "test_one",
14 | "time" : {
15 | "start" : 1562125512194,
16 | "stop" : 1562125517470,
17 | "duration" : 5276
18 | },
19 | "status" : "passed",
20 | "severity" : "normal"
21 | }, {
22 | "uid" : "627d1a6748cffb3a",
23 | "name" : "test_login",
24 | "time" : {
25 | "start" : 1562125597087,
26 | "stop" : 1562125601565,
27 | "duration" : 4478
28 | },
29 | "status" : "passed",
30 | "severity" : "normal"
31 | } ]
--------------------------------------------------------------------------------
/report/widgets/suites.json:
--------------------------------------------------------------------------------
1 | {
2 | "total" : 1,
3 | "items" : [ {
4 | "uid" : "0cc86a2310b4d245e3f2a5a97552b3a2",
5 | "name" : "tests.test_case",
6 | "statistic" : {
7 | "failed" : 1,
8 | "broken" : 0,
9 | "skipped" : 0,
10 | "passed" : 2,
11 | "unknown" : 0,
12 | "total" : 3
13 | }
14 | } ]
15 | }
--------------------------------------------------------------------------------
/report/widgets/summary.json:
--------------------------------------------------------------------------------
1 | {
2 | "reportName" : "Allure Report",
3 | "testRuns" : [ ],
4 | "statistic" : {
5 | "failed" : 1,
6 | "broken" : 0,
7 | "skipped" : 0,
8 | "passed" : 2,
9 | "unknown" : 0,
10 | "total" : 3
11 | },
12 | "time" : {
13 | "start" : 1562124266533,
14 | "stop" : 1562125601565,
15 | "duration" : 1335032,
16 | "minDuration" : 719,
17 | "maxDuration" : 5276,
18 | "sumDuration" : 10473
19 | }
20 | }
--------------------------------------------------------------------------------
/requirement.txt:
--------------------------------------------------------------------------------
1 | allure-pytest==2.8.6
2 | allure-python-commons==2.8.6
3 | Appium-Python-Client==0.47
4 | atomicwrites==1.3.0
5 | attrs==19.3.0
6 | certifi==2019.9.11
7 | chardet==3.0.4
8 | colorama==0.4.1
9 | colorlog==4.0.2
10 | ddt==1.2.1
11 | decorator==4.4.1
12 | facebook-wda==0.4.1
13 | filetype==1.0.5
14 | har2case==0.3.1
15 | httprunner==2.3.1
16 | idna==2.8
17 | importlib-metadata==0.23
18 | Jinja2==2.10.3
19 | jsonpath==0.82
20 | MarkupSafe==1.1.1
21 | more-itertools==7.2.0
22 | numpy==1.17.3
23 | opencv-python==4.1.1.26
24 | packaging==19.2
25 | Pillow==6.2.1
26 | pipenv==2018.11.26
27 | pluggy==0.13.0
28 | py==1.8.0
29 | pyparsing==2.4.2
30 | pytest==5.2.1
31 | PyYAML==5.1.2
32 | requests==2.22.0
33 | requests-toolbelt==0.9.1
34 | retry==0.9.2
35 | selenium==3.141.0
36 | six==1.12.0
37 | urllib3==1.25.6
38 | virtualenv==16.7.5
39 | virtualenv-clone==0.5.3
40 | wcwidth==0.1.7
41 | zipp==0.6.0
42 |
--------------------------------------------------------------------------------
/run.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | import os
3 |
4 | PATH = lambda p: os.path.abspath(
5 | os.path.join(os.path.dirname(__file__), p)
6 | )
7 |
8 | if __name__=='__main__':
9 | # pytest.main(['-v','--maxfail=3','./tests/test_case/','--alluredir','/tmp/my_allure_results','--clean'])
10 | pytest.main(['-v','--maxfail=3','./tests/test_case/','--alluredir','/Users/luokai/PycharmProjects/UIautocn/tmp/my_allure_results'])
11 |
--------------------------------------------------------------------------------
/run_android.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | import os
3 | import subprocess
4 | import time
5 |
6 | PATH = lambda p: os.path.abspath(
7 | os.path.join(os.path.dirname(__file__), p)
8 | )
9 |
10 | def kill_adb():
11 | os.popen("killall adb")
12 | os.system("adb start-server")
13 |
14 | if __name__=='__main__':
15 | cmd = "appium --session-override -p 4700 -bp 4701 -U emulator-5554"
16 | subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=1,close_fds=True)
17 | time.sleep(10)
18 | pytest.main(['-v','--maxfail=3','./tests/android_test_case/test_android_ad.py','--html=./report/html/report.html'])
--------------------------------------------------------------------------------
/run_iOS.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | import os
3 |
4 | PATH = lambda p: os.path.abspath(
5 | os.path.join(os.path.dirname(__file__), p)
6 | )
7 |
8 | if __name__=='__main__':
9 | pytest.main(['-v','--maxfail=3','./tests/iOS_test_case/','--alluredir','/Users/kevin/Project/UIautocn/tmp/my_allure_results'])
10 |
--------------------------------------------------------------------------------
/tests/android_test_case/105.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/android_test_case/105.apk
--------------------------------------------------------------------------------
/tests/android_test_case/__pycache__/conftest.cpython-36-pytest-5.0.0.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/android_test_case/__pycache__/conftest.cpython-36-pytest-5.0.0.pyc
--------------------------------------------------------------------------------
/tests/android_test_case/__pycache__/test_android_contacts.cpython-36-pytest-5.0.0.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/android_test_case/__pycache__/test_android_contacts.cpython-36-pytest-5.0.0.pyc
--------------------------------------------------------------------------------
/tests/android_test_case/conftest.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | import allure
3 | import yaml
4 | import os
5 | from appium import webdriver
6 |
7 | from run import PATH
8 |
9 |
10 | APPIUM_LOCAL_HOST_URL = 'http://localhost:4723/wd/hub'
11 | PLATFORM_VERSION = '9'
12 |
13 | @pytest.fixture(scope="function")
14 | def getDriver(request):
15 | desired_caps = {
16 | 'appPackage': 'com.addcn.car8891',
17 | 'appActivity': 'com.addcn.car8891.view.ui.activity.WelcomeActivity',
18 | 'platformName': 'android',
19 | 'platformVersion': PLATFORM_VERSION,
20 | 'deviceName': '4d9b81a6',
21 | # 'app': PATH('./tests/android_test_case/105.apk'),
22 | 'autoGrantPermissions': True,
23 | 'automationName': "uiautomator2"
24 | }
25 | driver = webdriver.Remote(APPIUM_LOCAL_HOST_URL, desired_caps)
26 | driver.implicitly_wait(5000)
27 | #
28 | # def fin():
29 | # driver.quit()
30 | #
31 | # request.addfinalizer(fin)
32 | return driver # provide the fixture value
33 |
--------------------------------------------------------------------------------
/tests/android_test_case/test_android_first.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | import allure
4 | import pytest
5 | from Business.Android.firstBusiness import FirstBusiness
6 | from Base import utils
7 | import sys
8 |
9 |
10 | @allure.feature('安卓首頁业务')
11 | class TestFirstAndroid(object):
12 | pass
13 |
14 | @allure.story('首頁-頂部搜尋')
15 | def test_search(self, getDriver):
16 | result = FirstBusiness(getDriver).close_mask().serch_keyword("測試")
17 | assert "測試" == result
18 |
19 | @allure.story('首頁-四大金剛')
20 | def test_four_nav(self, getDriver):
21 | result = FirstBusiness(getDriver).check_four_nav()
22 | assert "便捷的汽車買賣交易平台" in result
23 |
24 | @allure.story('首頁-8891看板')
25 | def test_8891news(self, getDriver):
26 | result = FirstBusiness(getDriver).check_8891news()
27 | assert result != None
28 |
29 |
30 | if __name__ == '__main__':
31 | pytest.main(['./tests/android_test_case/', '--setup-show', '--html=./report/html/report.html'])
32 |
--------------------------------------------------------------------------------
/tests/iOS_test_case/3.5.1.ipa:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/iOS_test_case/3.5.1.ipa
--------------------------------------------------------------------------------
/tests/iOS_test_case/conftest.py:
--------------------------------------------------------------------------------
1 | import pytest
2 | import allure
3 | import yaml
4 | import os
5 | from appium import webdriver
6 |
7 | from run import PATH
8 |
9 |
10 | APPIUM_LOCAL_HOST_URL = 'http://localhost:4723/wd/hub'
11 | PLATFORM_VERSION = '9'
12 |
13 | @pytest.fixture(scope="class")
14 | def getDriver(request):
15 | desired_caps = {
16 | "platformName": "iOS",
17 | "automationName": "XCUITest",
18 | "autoAcceptAlerts": True,
19 | "noReset": True,
20 | "platformVersion": "13.0",
21 | "deviceName": "iPhone Simulator",
22 | "app": "/Users/kevin/Project/UIautocn/tests/iOS_test_case/3.5.1.1.ipa"
23 | }
24 | driver = webdriver.Remote(APPIUM_LOCAL_HOST_URL, desired_caps)
25 | driver.implicitly_wait(5000)
26 |
27 | return driver
28 |
--------------------------------------------------------------------------------
/tests/iOS_test_case/test_iOS_ad.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python
2 | # -*- coding: utf-8 -*-
3 | import allure
4 | import os
5 | import pytest
6 | from PIL import Image
7 | from time import sleep
8 | from Base import utils
9 | import cv2
10 | import numpy as np
11 |
12 | from functools import reduce
13 | from appium import webdriver
14 |
15 | # Returns abs path relative to this file and not cwd
16 | # PATH = lambda p: os.path.abspath(
17 | # os.path.join(os.path.dirname(__file__), p)
18 | # )
19 | from run import PATH
20 |
21 |
22 | @allure.feature('iOS廣告业务')
23 | class TestAdvertAndroid(object):
24 |
25 | @allure.story('首次启动app')
26 | def test_first_open(self, getDriver):
27 | getDriver.find_element_by_accessibility_id("20181026 close").click()
28 | assert True
29 |
30 |
31 | @allure.story('顶部banner')
32 | def test_top_banner(self, getDriver):
33 | result=[]
34 | elementValue="name == 'home_banner0'"
35 |
36 | getDriver.find_element_by_ios_predicate("name == 'home_banner0'").click()
37 |
38 | # 截取banner图片,并加入list
39 | # TEMP_FILE1 = PATH("./tmp/usedCar_screenshot/top_banner1.png")
40 | # TEMP_FILE1 = utils.getElementImgHashByPredicate(getDriver, TEMP_FILE1, elementValue)
41 | # result.append(TEMP_FILE1)
42 | # getDriver.find_element_by_ios_predicate("name == 'home_banner0'").click()
43 |
44 | assert True
45 |
46 | if __name__ == '__main__':
47 | pytest.main(['./tests/iOS_test_case/'])
48 |
--------------------------------------------------------------------------------
/tests/test_case/__pycache__/conftest.cpython-36-pytest-5.0.0.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/test_case/__pycache__/conftest.cpython-36-pytest-5.0.0.pyc
--------------------------------------------------------------------------------
/tests/test_case/__pycache__/test_pytest.cpython-36-pytest-5.0.0.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/test_case/__pycache__/test_pytest.cpython-36-pytest-5.0.0.pyc
--------------------------------------------------------------------------------
/tests/test_case/__pycache__/test_pytest2.cpython-36-pytest-5.0.0.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lk236225128/UIautocn/9fa58e7ec4ca742727497266bf3681602db71699/tests/test_case/__pycache__/test_pytest2.cpython-36-pytest-5.0.0.pyc
--------------------------------------------------------------------------------
/tmp/my_allure_results/01daa194-78ab-4b7a-9be7-6ad4cfaaf980-result.json:
--------------------------------------------------------------------------------
1 | {"name": "test_two", "status": "failed", "statusDetails": {"message": "AssertionError: assert '百度一下' in 'test1111_百度搜索'", "trace": "self =