如何点击 href 链接?

时间:2021-03-24 04:37:39

标签: python html selenium href

我尝试使用 driver.find_element_by_id // link_text // 部分链接文本,我应该使用什么来访问这个 href。我收到 No such Element Exception 。任何帮助将不胜感激 tysm。

    
<a href="../s-reminderNotice.asp?fname=b%2D3c%2DpLessonBooking%2Easp%3Flimit%3Dpl" 
class="sidelinkbold" target="mainFrame" onmouseover=" 
window.status='Practical Training Booking'; return true" onmouseout="window.status=' '; 
return true">Booking without Fixed Instructor</a>


解决了;元素在 IFRAME 中;不得不将框架切换到访问元素

3 个答案:

答案 0 :(得分:0)

尝试使用下面的 WebElement 然后点击它:

//a[contains(text(),'Booking without Fixed Instructor')]

答案 1 :(得分:0)

driver.find_element_by_class_name("sidelinkbold").click()

它有一个简单的类名,可以用来点击。

答案 2 :(得分:0)

尝试使用:

webDriver.findElement(By.xpath("//a[@href='YOUR LINK']")).click();
相关问题