python+appium如何获取元素内容的颜色
手机端测试,uiautomatorviewer获取的元素属性如图所示,可以定位到元素及内容,但是无颜色属性,无法获取该元素中文本的颜色,请问大神们,如果实现手机端元素内容...
手机端测试,uiautomatorviewer获取的元素属性如图所示,可以定位到元素及内容,但是无颜色属性,无法获取该元素中文本的颜色,请问大神们,如果实现手机端元素内容颜色的获取,比如A条件下是红色,那么断言的时候,如何实现?
展开
展开全部
#重写元素定位的方法
class Action(object):
#初始化
def __init__(self, se_driver):
self.driver = se_driver
#通过resource-i定位
def findId(self, id):
try:
f = self.driver.find_element_by_id(id)
return f
except Exception as e:
print("未找到%s"%(id))
#通过class定位
def findClassName(self, name):
try:
f = self.driver.find_element_by_class_name(name)
return f
except Exception as e:
print("未找到%s"%(name))
#通过text定位
def findAU(self, name):
try:
f = self.driver.find_element_by_android_uiautomator('text(\"' + name +'\")')
return f
except Exception as e:
print("未找到%s"%(name))
#通过xpath定位
def findXpath(self, xpath):
try:
f = self.driver.find_element_by_xpath(xpath)
return f
except Exception as e:
print("未找到%s"%(xpath))
#通过content-desc
def findAI(self, content_desc):
try:
f = self.driver.find_element_by_access
class Action(object):
#初始化
def __init__(self, se_driver):
self.driver = se_driver
#通过resource-i定位
def findId(self, id):
try:
f = self.driver.find_element_by_id(id)
return f
except Exception as e:
print("未找到%s"%(id))
#通过class定位
def findClassName(self, name):
try:
f = self.driver.find_element_by_class_name(name)
return f
except Exception as e:
print("未找到%s"%(name))
#通过text定位
def findAU(self, name):
try:
f = self.driver.find_element_by_android_uiautomator('text(\"' + name +'\")')
return f
except Exception as e:
print("未找到%s"%(name))
#通过xpath定位
def findXpath(self, xpath):
try:
f = self.driver.find_element_by_xpath(xpath)
return f
except Exception as e:
print("未找到%s"%(xpath))
#通过content-desc
def findAI(self, content_desc):
try:
f = self.driver.find_element_by_access
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询