如何使用Python单击WebDriver中的链接?

时间:2013-05-02 11:38:02

标签: python webdriver selenium-chromedriver

<tr><td class=wb><a href="javascript:void(fight())" style='text-decoration:none'><b>Click here!</a></td></tr>

您好,如何点击此网址?

2 个答案:

答案 0 :(得分:1)

我用过:

driver.find_element_by_link_text("Click here!").click()

答案 1 :(得分:0)

我不确定,但试试这个:

elements = driver.find_elements_by_tag_name("td")
for element in elements:
    if element.text == "Click here!":
        element.click()

或者:

elements  = find_elements_by_class_name("wb")
for element in elements:
    if element.text == "Click here!":
        element.click()