Commit 2658bac2 authored by Betty周薇薇's avatar Betty周薇薇

python-app

parent 0e868046
......@@ -51,6 +51,8 @@ el1.get_attribute("class")
# - send_keys("输入的内容")
driver.tap([(984, 56)], duration=100)
driver.find_element(By.ID, 'android:id/search_src_text').send_keys("安全")
driver.find_element(By.XPATH,'//*[@test="显示"]')
driver.find_element(By.CLASS_NAME,'android.widget.ImageView')
time.sleep(5)
driver.quit()
......@@ -34,8 +34,20 @@ driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_capabilities=d
# print(el1.text)
# print(el2.text)
# driver.drag_and_drop(el1, el2)
driver.drag_and_drop(driver.find_element(By.XPATH, "//*[@text='浏览器']"), driver.find_element(By.XPATH, "//*[@text='开发者头条']"))
# 通过元素的相对位置进行滚动
el1 = driver.find_element(By.XPATH, '//*[@text="应用"]')
el2 = driver.find_element(By.XPATH, '//*[@text="蓝牙"]')
# 常见元素识别及动作
driver.find_element(By.ID, 'android:id/search_src_text').send_keys("安全")
driver.find_element(By.XPATH,'//*[@test="显示"]').click()
driver.find_element(By.CLASS_NAME,'android.widget.ImageView').click()
driver.tap([(984, 56)], duration=100)
# 常见操作
driver.drag_and_drop(driver.find_element(By.XPATH, "//*[@text='浏览器']"),
driver.find_element(By.XPATH, "//*[@text='开发者头条']"))
driver.swipe(144, 1759, 144, 943)
driver.scroll(el1, el2)
time.sleep(5)
driver.quit()
......@@ -8,11 +8,11 @@ from common.driver import get_app_driver
class KeyWord:
def __init__(self, driver, *args):
self.driver = driver
#显示等待:在5秒事件里面,每隔0.5秒调用一次until中的方法,直到返回值为True
def wait(self, func,*args):
return WebDriverWait(self.driver, 5).until(func)
......@@ -29,7 +29,7 @@ class KeyWord:
else:
return True
self.wait(f) # 通过self对象,调用类方法发显式等待
self.wait(f) # 通过self对象,调用类方法发显式等待
return self.driver.find_element(by, value) # 通过selenium本身元素定位方法进行等待完毕之后再定位
# def click(self, loc: str, by=By.XPATH, *args):
......@@ -42,7 +42,7 @@ class KeyWord:
el1.click()
# 输入关键字封装
def input(self, loc: str, by=By.XPATH, content=""):
def input(self, loc: str, by, content=""):
el1 = self.find_element(by, loc)
el1.send_keys(content)
......@@ -67,6 +67,12 @@ class KeyWord:
def tap(self, positions: list, duration:int,*args):
self.driver.tap(positions, duration)
def scroll(self,a,b,by,*args,duration:int =0):
et1 = self.find_element(by,a)
et2 = self.find_element(by,b)
print("******************进入scroll***********************")
self.driver.scroll(et1,et2)
def screen_shot(self, name:str,*args):
pic_name = './data/image/'+name+'.png'
pic_name2 = name+'.png'
......
This diff is collapsed.
"Epic","Feature","Story","FAILED","BROKEN","PASSED","SKIPPED","UNKNOWN"
"","","","0","0","1","0","0"
"","","","0","1","0","0","0"
{
"uid" : "b1a8273437954620fa374b796ffaacdd",
"name" : "behaviors",
"children" : [ {
"name" : "test_login",
"uid" : "352adbf52f68576c",
"uid" : "2aa0433f83fd75b4",
"parentUid" : "b1a8273437954620fa374b796ffaacdd",
"status" : "passed",
"status" : "broken",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"flaky" : false,
"parameters" : [ ]
} ]
} ],
"name" : "behaviors"
}
\ No newline at end of file
"Category","FAILED","BROKEN","PASSED","SKIPPED","UNKNOWN"
"Test defects","0","1","0","0","0"
{
"uid" : "4b4757e66a1912dae1a509f688f20b0f",
"name" : "categories",
"children" : [ ]
"children" : [ {
"name" : "Test defects",
"children" : [ {
"name" : "selenium.common.exceptions.TimeoutException: Message: \nStacktrace:\nNoSuchElementError: An element could not be located on the page using the given search parameters.\n at AndroidUiautomator2Driver.findElOrEls (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-driver\\lib\\commands\\find.js:75:11)",
"children" : [ {
"name" : "test_login",
"uid" : "2aa0433f83fd75b4",
"parentUid" : "b3796e61d76d739690edcb2dcbb05d9e",
"status" : "broken",
"time" : {
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "b3796e61d76d739690edcb2dcbb05d9e"
} ],
"uid" : "bdbf199525818fae7a8651db9eafe741"
} ],
"name" : "categories"
}
\ No newline at end of file
{
"uid" : "83edc06c07f9ae9e47eb6dd1b683e4e2",
"name" : "packages",
"children" : [ {
"name" : "testcases.test_app_galaxy",
"children" : [ {
"name" : "test_login",
"uid" : "352adbf52f68576c",
"uid" : "2aa0433f83fd75b4",
"parentUid" : "e57d3ded8c71cbcde699702f02cf7a3a",
"status" : "passed",
"status" : "broken",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "testcases.test_app_galaxy"
} ]
} ],
"name" : "packages"
}
\ No newline at end of file
"Status","Name","Duration in ms","Description"
"passed","testcases.test_app_galaxy.login#test_login","22057",""
"broken","testcases.test_app_galaxy.login#test_login","97724",""
{
"uid" : "98d3104e051c652961429bf95fa0b5d6",
"name" : "suites",
"children" : [ {
"name" : "testcases",
"children" : [ {
......@@ -9,13 +8,13 @@
"name" : "login",
"children" : [ {
"name" : "test_login",
"uid" : "352adbf52f68576c",
"uid" : "2aa0433f83fd75b4",
"parentUid" : "4850eb8c0c6ae56b8232b8c8761bfdef",
"status" : "passed",
"status" : "broken",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"flaky" : false,
"parameters" : [ ]
......@@ -25,5 +24,6 @@
"uid" : "c442c61bd55e9f6197e608bc59bd4c2c"
} ],
"uid" : "b51346658ccdb9db01a6b5f6c12deab1"
} ]
} ],
"name" : "suites"
}
\ No newline at end of file
{
"uid" : "ab17fc5a4eb3bca4b216b548c7f9fcbc",
"name" : "timeline",
"children" : [ {
"name" : "DESKTOP-MKSHDA6",
"children" : [ {
"name" : "24172-MainThread",
"name" : "1716-MainThread",
"children" : [ {
"name" : "test_login",
"uid" : "352adbf52f68576c",
"parentUid" : "23cf00869d8f77c401d20b7d1e83d2bd",
"status" : "passed",
"uid" : "2aa0433f83fd75b4",
"parentUid" : "4995988a6f46f8d92468b08f8cfc0361",
"status" : "broken",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"flaky" : false,
"parameters" : [ ]
} ],
"uid" : "23cf00869d8f77c401d20b7d1e83d2bd"
"uid" : "4995988a6f46f8d92468b08f8cfc0361"
} ],
"uid" : "d375ea80cb48e53379a497e900e13f5a"
} ]
} ],
"name" : "timeline"
}
\ No newline at end of file
launch_status failed=0 1708948817000000000
launch_status broken=0 1708948817000000000
launch_status passed=1 1708948817000000000
launch_status skipped=0 1708948817000000000
launch_status unknown=0 1708948817000000000
launch_time duration=22057 1708948817000000000
launch_time min_duration=22057 1708948817000000000
launch_time max_duration=22057 1708948817000000000
launch_time sum_duration=22057 1708948817000000000
launch_retries retries=0 1708948817000000000
launch_retries run=1 1708948817000000000
launch_status failed=0 1709726836000000000
launch_status broken=1 1709726836000000000
launch_status passed=0 1709726836000000000
launch_status skipped=0 1709726836000000000
launch_status unknown=0 1709726836000000000
launch_time duration=97724 1709726836000000000
launch_time min_duration=97724 1709726836000000000
launch_time max_duration=97724 1709726836000000000
launch_time sum_duration=97724 1709726836000000000
launch_problems test_defects=1 1709726836000000000
launch_retries retries=0 1709726836000000000
launch_retries run=1 1709726836000000000
launch_status_failed 0
launch_status_broken 0
launch_status_passed 1
launch_status_broken 1
launch_status_passed 0
launch_status_skipped 0
launch_status_unknown 0
launch_time_duration 22057
launch_time_min_duration 22057
launch_time_max_duration 22057
launch_time_sum_duration 22057
launch_time_duration 97724
launch_time_min_duration 97724
launch_time_max_duration 97724
launch_time_sum_duration 97724
launch_problems_test_defects 1
launch_retries_retries 0
launch_retries_run 1
[ {
"data" : { }
"data" : {
"Test defects" : 1
}
} ]
\ No newline at end of file
[ {
"data" : {
"duration" : 22057
"duration" : 97724
}
} ]
\ No newline at end of file
[ {
"data" : {
"failed" : 0,
"broken" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 1,
"passed" : 0,
"unknown" : 0,
"total" : 1
}
......
......@@ -2,19 +2,20 @@
"a418dfbad2794809d87e8d8e21845021" : {
"statistic" : {
"failed" : 0,
"broken" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 1,
"passed" : 0,
"unknown" : 0,
"total" : 1
},
"items" : [ {
"uid" : "352adbf52f68576c",
"status" : "passed",
"uid" : "2aa0433f83fd75b4",
"status" : "broken",
"statusDetails" : "selenium.common.exceptions.TimeoutException: Message: \nStacktrace:\nNoSuchElementError: An element could not be located on the page using the given search parameters.\n at AndroidUiautomator2Driver.findElOrEls (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-driver\\lib\\commands\\find.js:75:11)",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
}
} ]
}
......
[ {
"data" : { }
"data" : {
"Test defects" : 1
}
} ]
\ No newline at end of file
{
"total" : 0,
"items" : [ ]
"total" : 1,
"items" : [ {
"uid" : "bdbf199525818fae7a8651db9eafe741",
"name" : "Test defects",
"statistic" : {
"failed" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 0,
"unknown" : 0,
"total" : 1
}
} ]
}
\ No newline at end of file
[ {
"data" : {
"duration" : 22057
"duration" : 97724
}
} ]
\ No newline at end of file
[ {
"uid" : "352adbf52f68576c",
"uid" : "2aa0433f83fd75b4",
"name" : "test_login",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"status" : "passed",
"status" : "broken",
"severity" : "normal"
} ]
\ No newline at end of file
[ {
"data" : {
"failed" : 0,
"broken" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 1,
"passed" : 0,
"unknown" : 0,
"total" : 1
}
......
[ {
"uid" : "352adbf52f68576c",
"uid" : "2aa0433f83fd75b4",
"name" : "test_login",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"status" : "passed",
"status" : "broken",
"severity" : "normal"
} ]
\ No newline at end of file
[ {
"uid" : "352adbf52f68576c",
"uid" : "2aa0433f83fd75b4",
"name" : "test_login",
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724
},
"status" : "passed",
"status" : "broken",
"severity" : "normal"
} ]
\ No newline at end of file
......@@ -5,9 +5,9 @@
"name" : "testcases",
"statistic" : {
"failed" : 0,
"broken" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 1,
"passed" : 0,
"unknown" : 0,
"total" : 1
}
......
......@@ -3,18 +3,18 @@
"testRuns" : [ ],
"statistic" : {
"failed" : 0,
"broken" : 0,
"broken" : 1,
"skipped" : 0,
"passed" : 1,
"passed" : 0,
"unknown" : 0,
"total" : 1
},
"time" : {
"start" : 1708948793267,
"stop" : 1708948815324,
"duration" : 22057,
"minDuration" : 22057,
"maxDuration" : 22057,
"sumDuration" : 22057
"start" : 1709726737596,
"stop" : 1709726835320,
"duration" : 97724,
"minDuration" : 97724,
"maxDuration" : 97724,
"sumDuration" : 97724
}
}
\ No newline at end of file
{"name": "test_login", "status": "broken", "statusDetails": {"message": "selenium.common.exceptions.TimeoutException: Message: \nStacktrace:\nNoSuchElementError: An element could not be located on the page using the given search parameters.\n at AndroidUiautomator2Driver.findElOrEls (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-driver\\lib\\commands\\find.js:75:11)", "trace": "xlsx content: \n| | 标记 | 内容 | 列1 | 列2 | 列3 |\n|-----|--------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------|-------|-------|\n| | swipe | 210 | 1600 | 210 | 2000 |\n| | swipe | 210 | 1600 | 210 | 2000 |\n| | click | //*[@text=\"确定\"] | xpath | | |\n| | click | /hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.widget.FrameLayout/android.view.ViewGroup/android.widget.ScrollView/android.view.ViewGroup/android.view.ViewGroup[3]/android.view.ViewGroup[5]/android.view.ViewGroup/android.view.ViewGroup/android.widget.TextView[2] | xpath | | |\n| | swipe | 210 | 1600 | 210 | 2000 |\n| | swipe | 210 | 1600 | 210 | 2000 |\n| >>> | click | //*[@text=\"确定\"] | xpath | | |\n| | click | //*[@text=\"下一步\"] | xpath | | |\nC:\\Python\\Python311\\Lib\\site-packages\\selenium\\webdriver\\support\\wait.py:94: TimeoutException\nMessage: \nStacktrace:\nNoSuchElementError: An element could not be located on the page using the given search parameters.\n at AndroidUiautomator2Driver.findElOrEls (C:\\Users\\ooo\\AppData\\Local\\Programs\\Appium\\resources\\app\\node_modules\\appium\\node_modules\\appium-android-driver\\lib\\commands\\find.js:75:11)"}, "attachments": [{"name": "log", "source": "c5621df3-e80f-4842-9205-40981a5e4675-attachment.txt", "type": "text/plain"}], "start": 1709726737596, "stop": 1709726835320, "uuid": "d370f04b-c01d-490e-8adf-2ac7266fb4f0", "historyId": "a418dfbad2794809d87e8d8e21845021", "testCaseId": "a418dfbad2794809d87e8d8e21845021", "fullName": "testcases.test_app_galaxy.login#test_login", "labels": [{"name": "parentSuite", "value": "testcases"}, {"name": "suite", "value": "test_app_galaxy"}, {"name": "subSuite", "value": "login"}, {"name": "host", "value": "DESKTOP-MKSHDA6"}, {"name": "thread", "value": "1716-MainThread"}, {"name": "framework", "value": "pytest"}, {"name": "language", "value": "cpython3"}, {"name": "package", "value": "testcases.test_app_galaxy"}]}
\ No newline at end of file
{"uuid": "3c232b32-de92-4737-9395-14b37bed0385", "children": ["d370f04b-c01d-490e-8adf-2ac7266fb4f0"], "befores": [{"name": "get_driver", "status": "passed", "start": 1709726737596, "stop": 1709726749867}], "afters": [{"name": "get_driver::0", "status": "passed", "start": 1709726835326, "stop": 1709726835326}], "start": 1709726737596, "stop": 1709726835326}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment