title: How to fill out a web form from excel file and get the resulting page source
body: <p>I'm trying to use this code on the below link, with the same concept (transfer the data from excel) and I face many errors.</p>
  <p>I need to change the code to match the entries.</p>
  <p><a href="https://docs.google.com/forms/d/e/1FAIpQLSek4lvyKCkjeKHJwRRSUdsNb4WCIohFNlog7YjeWVzmEr3DQQ/viewform" rel="nofollow noreferrer">https://docs.google.com/forms/d/e/1FAIpQLSek4lvyKCkjeKHJwRRSUdsNb4WCIohFNlog7YjeWVzmEr3DQQ/viewform</a></p>
  <pre><code>from selenium import webdriver
  import sys
  import time
  import os
  import pyautogui
  import webbrowser
  import openpyxl
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support import expected_conditions as EC
  from selenium.webdriver.common.by import By
  from selenium.webdriver.support.select import Select
  from openpyxl import Workbook
  from openpyxl import load_workbook
  
  chrome_path =r&quot;C:/Users/asous/Desktop/New folder1/chromedriver.exe&quot;
  driver = webdriver.Chrome(chrome_path)
  driver.get(&quot;https://docs.google.com/forms/d/e/1FAIpQLSek4lvyKCkjeKHJwRRSUdsNb4WCIohFNlog7YjeWVzmEr3DQQ/viewform&quot;)
  
  def sendvalues(driver):
  
      wb = load_workbook('C:/Users/asous/Desktop/New folder1/afeef.xlsx')
      ws = wb.active
  
      firstname = driver.find_element_by_xpath('//*[@id=&quot;mG61Hd&quot;]/div[2]/div/div[2]/div[1]/div/div/div[2]/div/div[1]/div/div[1]/input')
      lastname = driver.find_element_by_xpath('//*[@id=&quot;mG61Hd&quot;]/div[2]/div/div[2]/div[2]/div/div/div[2]/div/div[1]/div/div[1]/input')
      firstn=ws.cell(row=x, column=1).value
      lastn=ws.cell(row=x, column=2).value
      firstname.send_keys(firstn)
      lastname.send_keys(lastn)
      table(driver)
  
  def table(driver):
      #rut = driver.find_element_by_xpath(&quot;&quot;&quot;//*[@id=&quot;rut&quot;]&quot;&quot;&quot;)
      #dv = driver.find_element_by_xpath(&quot;&quot;&quot;//*[@id=&quot;wrapper&quot;]/form/table[1]/tbody/tr[3]/td[2]/input&quot;&quot;&quot;)
      #nombre = driver.find_element_by_xpath(&quot;&quot;&quot;//*[@id=&quot;wrapper&quot;]/form/table[1]/tbody/tr[4]/td[2]/input&quot;&quot;&quot;)
      coma = &quot;,&quot;
      wb = load_workbook('C:/Users/asous/Desktop/New folder1/afeef.xlsx')
      ws = wb.active
      rutvalue=  ws.cell(row=x, column=1).value
      table_elements = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.XPATH, &quot;//table[@class = 'grilla']&quot;)))
  
      for table_element in table_elements:
          for row in table_element.find_elements_by_xpath(&quot;.//tr&quot;):
              text_file = open(&quot;Output2.txt&quot;, &quot;a&quot;)
              text_file.write(str(rutvalue)+str(coma)+str(row.text)+'\n')
              text_file.close()
              rut.clear()
              dv.clear()
              nombre.clear()
  
  sendvalues(driver)
  for x in range(1,1000):
     sendvalues(driver)
  </code></pre>
  <p>one of the issues is the web opened without any action (fil the data), the other mention below</p>
  <p>Traceback (most recent call last):
  File &quot;C:/Users/asous/PycharmProjects/project_traning/Web automation/Web Aut 2.py&quot;, line 82, in 
  sendvalues(driver)
  File &quot;C:/Users/asous/PycharmProjects/project_traning/Web automation/Web Aut 2.py&quot;, line 56, in sendvalues
  firstn=ws.cell(row=x, column=1).value
  NameError: name 'x' is not defined</p>