0

I am trying to automate sending a text message using python & selenium from https://voice.google.com/about. I can login with my username and password but, as soon as I login and try to click on a message icon on left hand side, it gives me error(10054, 'An existing connection was forcibly closed by the remote host')

try:
    url = "https://voice.google.com/about"
    driver.get(url)
    time.sleep(5)
    print("Session id 1", driver.session_id)

    # Click on a GET GOOGLE VOICE
    WebDriverWait(driver, 60).until(
        EC.element_to_be_clickable((By.XPATH, '//*[@id="heroToggle"]/button/span'))).click()

    print("Clicked on a get google voice")

    # Click on a WEB
    WebDriverWait(driver, 60).until(
        EC.element_to_be_clickable((By.XPATH, '//*[@id="heroToggle"]/div/button[3]'))).click()
    print("Clicked a C2C button.")

    # Enter username and password

    WebDriverWait(driver, 30).until(EC.element_to_be_clickable((By.ID, 'identifierId')))
    email = driver.find_element_by_id('identifierId')
    email.send_keys('username')
    nextBtn = driver.find_element_by_xpath('//*[@id="identifierNext"]/content/span')
    nextBtn.click()

    # Enter password
    password = driver.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input')
    password.send_keys('password')
    nextBtn = driver.find_element_by_xpath('//*[@id="passwordNext"]/content')
    nextBtn.click()
    print("Session id 2", driver.session_id)
    # driver.refresh()
    # time.sleep(10)

    # Click on a message icon. THIS IS WHERE I GET AN ERROR

    # WebDriverWait(driver, 60).until(EC.element_to_be_clickable((By.CSS_SELECTOR, '.material-icons-extended.IhMtsf-Bz112c'))).click()
    msg = driver.find_element_by_css_selector('.gb_ye.gb_Ae')
    msg.click()
    print("Session id 3", driver.session_id)

except Exception as e:
    print("Error===>", e)

I checked other answers but, none were useful.

I am not sure what I am doing wrong. Any help would really be appreciated.

PRK
  • 411
  • 3
  • 6
  • 19
  • Try to download [last chromedriver version](https://chromedriver.storage.googleapis.com/index.html?path=2.45/). Also note that putting all your code into `try` block with catching common Exception is a bad practice. Consider to split your code into several `try`/`except` blocks (if needed) with specifying exact Exception you need to catch – Andersson Dec 17 '18 at 09:51
  • Thanks, @Andersson. It solved my problem. Can you help me to understand why I had to update the drivers and how did you reach to this solution? TIA – PRK Dec 18 '18 at 07:26
  • Each Chrome version supports particular range of chromedriver versions, so if you have Chrome auto-update feature you can face versions incompatibility issue. So in case of some weird OSErrors or Connection errors the first thing to try is to download up-to-date driver – Andersson Dec 18 '18 at 08:50

0 Answers0