def get_element(self,info):
'''
获取元素element
@ parame by 定位方式
@ parame value 定位置
@ return element 返回一个元素
'''
by,value = self.get_local_element(info)
element = None
#try:
if by == 'id':
element = self.driver.find_element_by_id(value)
elif by == 'name':
element = self.driver.find_element_by_name(value)
elif by == 'css':
element = self.driver.find_elements_by_css_selector(value)
elif by == 'class':
element = self.driver.find_element_by_class_name(value)
else:
element = self.driver.find_element_by_xpath(value)
#except:
#print("定位方式:",by,"定位值:",value,"定位出现错误,没有定位成功")
return self.element_isdisplay(element)
我在element函数下面把try...except语句注释掉就解决问题了
为什么不注释会报错(“”bool“的实例没有”find_element_by_id“成员”),为什么需要注释呢