title: Selenium input text that has dropdown & hidden values
body: <p>I am writing a python script to input text, that then has a dropdown appear to select from a list of items. These items are all hidden values and are not inputted to the webpage until selected by clicking on said item.</p>
  
  <p>Specifically I am attempting to input data on Fitbits website to track food (a thing for work, but it is tedious to input food consumption each day). I would like to automate this :) </p>
  
  <p>My script currently looks like this...</p>
  
  <pre><code>            #! python3
              # fitbitSubmitFood.py this script submits the food log on fitbit.com
  
              from selenium import webdriver
              from selenium.webdriver.common.by import By
              from selenium.webdriver.support.ui import WebDriverWait
              from selenium.webdriver.support import expected_conditions as EC
  
              browser = webdriver.Chrome()
  
              # open webpage to log food
              browser.get('https://www.fitbit.com/foods/log')
  
              # login to the website
              # email username input
              emailSelect = browser.find_element_by_xpath('//*[@id="loginForm"]/fieldset/dl/dd[1]/input')
              emailSelect.send_keys('EMAIL')
              # email password input
              inputPassword = browser.find_element_by_xpath('//*[@id="loginForm"]/fieldset/dl/dd[2]/input')
              inputPassword.send_keys('PASSWORD')
              # click log in
              clickLogin = browser.find_element_by_xpath('//*[@id="loginForm"]/div[1]/button')
              clickLogin.click() # clicky click!
  
              # input What did you eat?
              foodSelect = browser.find_element_by_xpath('//*[@id="foodselectinput"]')
              foodSelect.send_keys('Pizza, Bread') # select by visible text
  
              # input How Much?
              howMuch = browser.find_element_by_xpath('//*[@id="quantityselectinput"]')
              howMuch.send_keys('3')
  
              # click Log Food
              logfood = browser.find_element_by_xpath('//*[@id="foodAutoCompButton"]')
              # logfood.click() # clicky click!
  
              # Close web browser
  </code></pre>
  
  <p>The current script above throws the following error.
  selenium.common.exceptions.InvalidElementStateException: Message: invalid element state</p>
  
  <p>So I have also tried suggestions from this stackoverflow question.
  <a href="https://stackoverflow.com/questions/41130985/entering-a-value-into-a-type-hidden-field-using-selenium-python">Entering a value into a type=&quot;hidden&quot; field using Selenium + Python</a></p>
  
  <pre><code>            WebDriverWait(foodSelect, 10).until(EC.visibility_of_element_located((By.XPATH,'//*[@id="foodId"]'))) # wait for hidden text to populate
  </code></pre>
  
  <p>This threw the following error...</p>
  
  <p>selenium.common.exceptions.TimeoutException: Message: </p>
  
  <p>Here is a snippet from the website</p>
  
  <pre><code>            input type="text" name="foodselectinput" id="foodselectinput" class="text columnFull yui-ac-input" maxlength="80" tabindex="1" autocomplete="off"
  </code></pre>
  
  <p>I can see the following on the website for the hidden value. This value is not passed to the webpage until after the food is selected from the drop down menu.</p>
  
  <pre><code>            input name="foodId" id="foodId" type="hidden" value="13272"
  </code></pre>
  
  <p>Note: I have already tried using the click method for the Pizza, Bread</p>
  
  <pre><code>            clickFood = browser.find_element_by_xpath('//*[@id="foodselectcontainer"]/div/div[2]/ul/li[1]/div/div[1]')
              clickFood.click() # click it!
  </code></pre>
  
  <p>This did not work. </p>
  
  <p>selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="foodselectcontainer"]/div/div[2]/ul/li[1]/div/div[1]"}</p>
  
  <p>The script cannot continue until the food item is selected on the webpage. Hence, the question.</p>
  
  <p>How would one pass the hidden value or select from a dropdown?</p>