Dmitry
Dmitry

Reputation: 3

How to click a link in WebDriver using Python?

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

Hi, how to click this url?

Upvotes: 0

Views: 4184

Answers (2)

Mark Rowlands
Mark Rowlands

Reputation: 5453

I'd have used:

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

Upvotes: 1

4d4c
4d4c

Reputation: 8159

I'm not sure, but try this:

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

Or:

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

Upvotes: 0

Related Questions