I have this HTML
<a href="/hyperlink" ><span class="gl11">text1</span> <br /><span class="UC">text2</span></a>
I want to get the hyperlink and click on it. I write:
link = driver.find_element_by_link_text('text')
link.click()
But the problem is there are two texts in between "a" tag. How do I modify the syntax?
答案 0 :(得分:1)
尝试以下代码:
link = driver.find_element_by_link_text('text1\ntext2')
link.click()
还可以使用"text1"
"text2"
或find_element_by_partial_link_text()
找到元素:
link = driver.find_element_by_partial_link_text('text1')
link.click()