0
我正試圖在頁面上找到一個鏈接,然後單擊它。下面是DOM的快照:如何對一個元組進行點擊操作?
這是我怎麼想找到它:
try:
PublishAPostButton = WebDriverWait(Driver.Instance,30).until(lambda d:Driver.Instance.find_element_by_xpath("//div[@class='articles-actions']/a[starts-with(text(),'Publish a post')]")).is_displayed(), "Link still not exists"
except:
print("Publish a post link not available")
else:
PublishAPostButton.click()
print("Publish a post link was clicked")
「嘗試」塊的執行沒有任何錯誤或異常,但它返回一個元組(不知道爲什麼!)。控制轉到「其他」並嘗試點擊。顯然,它不能單擊一個元組,並因此給出錯誤。這是我得到的錯誤:AttributeError:'元組'對象沒有'點擊'屬性。 我不明白的是它是如何返回一個元組?請幫忙!
但Try塊要麼返回真或假。在else塊中,單擊()操作不能在布爾值上執行 –
不,try塊將該元素分配給變量PublishAdPostButton –