2

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 www.bing.com, I could successfully click this link by calling:

driver.get("http://www.bing.com")
driver.implicitly_wait(20)
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!

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

3
  • Do not use implicit wait as it's not working as expected, use explicit wait instead selenium-python.readthedocs.io/waits.html#explicit-waits Commented Oct 31, 2016 at 16:10
  • Just to be sure I tested it in Selenium 2 and Chrome and can confirm the script is all right and the targeted element does exist. Commented Oct 31, 2016 at 16:12
  • @Andersson, yes, you are correct! once I switch to explicit wait as the result from alecxe, the problem is resolved. Commented Oct 31, 2016 at 19:13

1 Answer 1

2

Wait for the link to be clickable:

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

wait = WebDriverWait(driver, 10)
sign_in = wait.until(EC.element_to_be_clickable((By.LINK_TEXT, "Sign in")))
sign_in.click()
Sign up to request clarification or add additional context in comments.

5 Comments

thanks for your answer, but I receive exactly the same error message
@user6651227 alright, please check the update. Thanks.
I just tested, using XPATH is just one way, but using WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.LINK_TEXT, "Sign in"))).click() still gives me the expected result. So I am guessing there might be some other parts causes the problem. Do you have any idea? thanks
@alecex, I know the reason, I should switch from implicit way to explicit wait as you did.
@user6651227 yeah, you are right, updated the answer accordingly. Thanks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.