rearThing
rearThing

Reputation: 632

selenium with python button click

I can access the tag below via css_selector but how do I do a button click?

<a title="Sign In" onclick="toggleLogin('signInBlock','regBenefitsBlock');" href="javascript:void(0);">Sign In</a>

Any idea would be appreciated.

Upvotes: 0

Views: 77

Answers (2)

Pedro Lobito
Pedro Lobito

Reputation: 99011

To execute JavaScript on selenium python you can use:

driver.execute_script("toggleLogin('signInBlock','regBenefitsBlock');")

Upvotes: 1

alecxe
alecxe

Reputation: 474151

Locate the button by link text and use click() method:

button = driver.find_element_by_link_text("Sign In")
button.click()

Upvotes: 3

Related Questions