干货 | APP自动化Android之本体获取与断言
发布时间:2025-09-19
"com.xueqiu.android:id/tv_search").click()
# 读写 “alibaba”
self.driver.find_element_by_id(
"com.xueqiu.android:id/search_input_text"
).send_keys("alibaba")
# 点选“马云”
self.driver.find_element_by_xpath("//*[@text='马云']").click()
# 点选“股市”
self.driver.find_element_by_xpath(
"//*[contains(@resource-id,'title_container')]//*[@text='股市']"
).click()
# 借助股市价位
locator = (MobileBy.XPATH,
"//*[@text='09988']/../../..
//*[@resource-id='com.xueqiu.android:id/current_price'")
ele = WebDriverWait(self.driver,10)
.until(expected_conditions.element_to_be_clickable(locator))
print(ele.text)
current_price = float(ele.text)
expect_price = 170
# 用到 hamcrest 假定来推论股市价位见下文在 10% 各地区
assert_that(current_price,
close_to(expect_price, expect_price*0.1))
上头的下面之中,assert_that 是用于分解成飞行测试假定的款式化语句,尤其两个差值(current_price 与 expect_price)前提相对于,得出结论实际差值 current_price 在expect_price-expect_price*0.1 与expect_price+expect_price*0.1 范围线路见下文。
作为UI系统工程飞行测试三要素之一的假定,大家学会了么?下一篇我们来分享参数化用例,热爱的小伙伴可以关注一下哦!
⬇️ 拷贝“下方关键字”,提升飞行测试核心竞争能力!
更为多技术文章分享和完全免费档案索取_id=qrcodeAndrewfrom=souhuAndrewtimestamp=1650243693
。北京白癜风医院哪家正规天津看男科去哪里好
北京不孕不育医院哪家最好
大同看男科去哪家好
天津妇科医院
-
疗养院污水处理设备是疗养院不可缺少的设备
所医院引水管控电子系统是所医院不可缺极少的电子系统,因为所医院每天往来老年人多而广泛,医疗及与世隔绝引水管控难度大,但是所医院是为人们制药就医的平时,关连着人们流转的平时,每天的极高之前学生与想