user6651227 user6651227 - 1 year ago 164
Python Question

python selenium to click a link

since I updated my firefox to 49.02 and selenium to 3.0.1, my previous code to sign in to my

bing account
does not work.

there is a
Sign in
link in
, I could successfully click this link by calling:

driver.find_element_by_link_text('Sign in').click()

however, after the upgrade, I receive a strange error message which contains no message at all:

selenium.common.exceptions.ElementNotVisibleException: Message:

if I only call
driver.find_element_by_link_text('Sign in')
, I will receive no error message. This seems like selenium could successfully locate this link, but somehow it can not click this button.

I have also tried to locate
Sign in
by it
class name
or by clicking the icon instead, but all such efforts are useless.

I do not know if the error is caused by Microsoft to block automated logging in or the error in my code. Helps appreciated!

driver.find_element_by_xpath('//a[span = "Sign in"]').click()
as suggested by
still does not resolve the issue.

Answer Source

Wait for the link to be clickable:

from import By
from import WebDriverWait
from import expected_conditions as EC

wait = WebDriverWait(driver, 10)
sign_in = wait.until(EC.element_to_be_clickable((By.LINK_TEXT, "Sign in")))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download