如何检查给定元素是否链接,以及如何对元素执行操作(显示或启用元素(?
link=driver.find_element_by_id("btn-baseFooter-termsOfUse") #element
if link.tag_name=='a': #validating the element
print('element is link')
else:
print('element is text')
def TermAndPrivacyPolicy(self):
sleep(10)
terms=driver.find_element(By.ID, "btn-baseFooter-termsOfUse")
if terms.tag_name == 'a':
print('element is: ',terms.tag_name)
else:
print('element is not link it is: ',terms.tag_name)
if terms.is_displayed() and terms.is_enabled()==True:
terms.click()
print(terms.'link is enabled, displayed and link is clicked')
sleep(2)
element=driver.find_element(By.ID, 'btn-termsConditions-close')
driver.execute_script("arguments[0].scrollIntoView();", element)
element.click()
else:
print('Link is neither enable or displayed')