title: PySimpleGUI with Selenium
body: <p>I've made a PySimpleGUI app with Selenium, it takes CSV values and puts them into a form and submits it, now however we need to send an input to the form.</p>
  <p>So I added this:</p>
  <pre><code> [sg.Multiline(size=(30, 5), key='deposit')],
  </code></pre>
  <p>But how do I reference it in the send_keys function that I'm using currently:</p>
  <pre><code>...
              mail_field.send_keys(line[13])
              phone_field.send_keys(line[16])
              deposit_field.send_keys('deposit') ?
              submit.click()
  </code></pre>
  <p>Thought I'd try values['deposit'] but that doesnt work either
  Entire code</p>
  <pre><code>import csv
  import time
  import threading
  from selenium import webdriver
  import PySimpleGUI as sg
  import os
  import sys
  
  
  def resource_path(relative_path):
  
      try:
          # PyInstaller creates a temp folder and stores path in _MEIPASS
          base_path = sys._MEIPASS
      except Exception:
          base_path = os.path.abspath(&quot;.&quot;)
  
      return os.path.join(base_path, relative_path)
  
  
  def make_window(theme):
  
      sg.theme('LightGrey')
      menu_def = [['&amp;Application', ['E&amp;xit']],
                  ['&amp;Help', ['&amp;About']]]
      right_click_menu_def = [[], ['Exit']]
  
      # Table Data
  
      input_layout = [[sg.Menu(menu_def, key='-MENU-')],
  
  
                      [sg.Button(&quot;Open File&quot;, button_color=(
                          'white', 'dodgerblue'))],
  
                      [sg.Text('Chrome Version')],
  
                      [sg.OptionMenu(values=(
                          '96', '97', '98'),  k='-OPTION MENU-', background_color='dodgerblue'), ],
                      
                       [sg.Multiline(size=(30, 5), key='deposit')],
  
                      [sg.Button('Submit', button_color=('white', '#Ed1941'))]]
  
      layout = [[sg.Text('Name', size=(35, 1), justification='center', font=(
          &quot;Helvetica&quot;, 16), relief=sg.RELIEF_RIDGE, k='-TEXT HEADING-', enable_events=True)]]
      layout += [[sg.TabGroup([[sg.Tab('Setup CSV and Chrome Version', input_layout),
  
                                ]], key='-TAB GROUP-', size=(400, 120))]]
  
      return sg.Window('Name', layout, icon='icon.ico', right_click_menu=right_click_menu_def)
  
  
  def main():
      window = make_window(sg.theme('LightGrey'))
  
      # This is an Event Loop
      while True:
          event, values = window.read(timeout=100)
          # keep an animation running so show things are happening
  
          if event not in (sg.TIMEOUT_EVENT, sg.WIN_CLOSED):
              print('============ Event = ', event, ' ==============')
              print('-------- Values Dictionary (key=value) --------')
              for key in values:
                  print(key, ' = ', values[key])
          if event in (None, 'Exit'):
              print(&quot;[LOG] Clicked Exit!&quot;)
              break
          elif event == 'About':
              print(&quot;[LOG] Clicked About!&quot;)
              sg.popup('',
                       'Select CSV file',
                       'Select Chrome Version',
                       'Submit',
                       '')
          elif event == 'Popup':
              print(&quot;[LOG] Clicked Popup Button!&quot;)
              sg.popup(&quot;You pressed a button!&quot;)
              print(&quot;[LOG] Dismissing Popup!&quot;)
  
          elif event == &quot;Open File&quot;:
              print(&quot;[LOG] Clicked Open File!&quot;)
              csv_file_selected = sg.popup_get_file('Choose your file')
              # sg.popup(&quot;You chose: &quot; + str(folder_or_file))
              # print(&quot;[LOG] User chose file: &quot; + str(folder_or_file))
  
  
  def run_selenium(window, file, driver):
  
      with open(file, 'rt') as csv_file:
          csv_reader = csv.reader(csv_file)
      # -------------------------------------------------------------------------------
      # Web Automation
      driver = webdriver.Chrome(executable_path=driver)
      driver.get('')
  
      fname_field = driver.find_element_by_xpath('//*[@id=&quot;FIRSTNAME&quot;]')
      lname_field = driver.find_element_by_xpath('//*[@id=&quot;LASTNAME&quot;]')
      phone_field = driver.find_element_by_xpath('//*[@id=&quot;PHONE&quot;]')
      mail_field = driver.find_element_by_xpath('//*[@id=&quot;EMAIL&quot;]')
      deposit_field = driver.find_element_by_xpath('//*[@id=&quot;DEPOSIT&quot;]')
      submit = driver.find_element_by_xpath(
          '//*[@id=&quot;sib-form&quot;]/div[8]/div/button')
  
      with open(file, 'rt', encoding='utf-8-sig') as csv_file:
          csv_reader = csv.reader(csv_file, delimiter=';')
          next(csv_reader)
          for line in csv_reader:
  
              time.sleep(3.0)
  
              fname_field.send_keys(line[10])
              lname_field.send_keys(line[11])
              mail_field.send_keys(line[13])
              phone_field.send_keys(line[16])
              deposit_field.send_keys(text) //Here
              submit.click()
  
      # Not to update GUI in thread, but generate an event which will be processed in event loop.
      window.write_event_value('Done', None)
  
  
  def main():
      # My GUI
      window = make_window(sg.theme())
      folder_or_file = None
      
      cd97 = resource_path('./chromedriver97.exe')
      cd98 = resource_path('./chromedriver98.exe')
      # Using your path for all the drivers of all versions
      paths = {
          '97': cd97,
          '98': cd98,
      }
  
      while True:
          event, values = window.read(timeout=100)
          # keep an animation running so show things are happening
  
          if event not in (sg.TIMEOUT_EVENT, sg.WIN_CLOSED):
              # print('============ Event = ', event, ' ==============')
              # print('-------- Values Dictionary (key=value) --------')
              for key in values:
                  print(key, ' = ', values[key])
          if event in (None, 'Exit'):
             # print(&quot;[LOG] Clicked Exit!&quot;)
              break
          elif event == 'About':
             # print(&quot;[LOG] Clicked About!&quot;)
              sg.popup('',
                       'Select CSV file',
                       'Select Chrome Version',
                       'Submit',
                       '')
          elif event == 'Popup':
             # print(&quot;[LOG] Clicked Popup Button!&quot;)
              sg.popup(&quot;You pressed a button!&quot;)
             # print(&quot;[LOG] Dismissing Popup!&quot;)
          elif event == &quot;Open File&quot;:
              #print(&quot;[LOG] Clicked Open File!&quot;)
              folder_or_file = sg.popup_get_file('Choose your file')
              # sg.popup(&quot;You chose: &quot; + str(folder_or_file))
              #print(&quot;[LOG] User chose file: &quot; + str(folder_or_file))
          elif event == 'Submit':
              version = values['-OPTION MENU-']
              if folder_or_file is None or version not in paths:
                #  print(&quot;No CSV file selected or wrong Chrome version selected&quot;)
                  continue
              # Using thread to avoid long time job will block and cause GUI no response
              threading.Thread(target=run_selenium, args=(
                  window, folder_or_file, paths[version])).start()
              # Disable Submit button to prevent submit again when threading
              window['Submit'].update(disabled=True)
            #  print('[LOG] Run Selenium ...')
          elif event == 'Done':
              # Enable Submit button when thread done
              window['Submit'].update(disabled=False)
             # print('[LOG] End Selenium')
  
      window.close()
  
  
  main()
  
  
  </code></pre>