def _get_link(self, the_link, link_type, link_text):
try:
links = self.pydriver.find_elements(By.XPATH, "//%s" % the_link)
except (NoSuchElementException, StaleElementReferenceException, WebDriverException), e:
ACLogger.log_and_print_error(
'_get_link: unable to find type(%s) links in UI, exception=%s' % (link_type, str(e)))
return False
clicked_it = False
for link in links:
if clicked_it is False and link.text == link_text:
try:
link.click()
except (NoSuchElementException, StaleElementReferenceException, WebDriverException), e:
ACLogger.log_and_print_error(
'_get_link: unable to click on type(%s) text(%s) in UI, exception=%s' % (link_type,link_text,str(e)))
return False
finally:
clicked_it = True
break
if clicked_it is False:
ACLogger.log_and_print_error(
'_get_link: unable to find link %s in UI ' % link_text)
return False
time.sleep(2)
return True
评论列表
文章目录