原文链接:https://testerhome.com/topics/7091
方法一:
def isElement(self,identifyBy,c):
'''
Determine whether elements exist
Usage:
isElement(By.XPATH,"//a")
'''
sleep(1)
flag=None
try:
if identifyBy == "id":
#self.driver.implicitly_wait(60)
self.driver.find_element_by_id(c)
elif identifyBy == "xpath":
#self.driver.implicitly_wait(60)
self.driver.find_element_by_xpath(c)
elif identifyBy == "class":
self.driver.find_element_by_class_name(c)
elif identifyBy == "link text":
self.driver.find_element_by_link_text(c)
elif identifyBy == "partial link text":
self.driver.find_element_by_partial_link_text(c)
elif i