I am attempting to import calendar events to google calendar through a csv file using Selenium and Python. I am unable to select the form element to input my file path into google. I have tried finding the element by xpath, cssselector and class name and I get the same error every time:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element
fileElem = browser.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form')
The example xpath shown above was copied directly through google chrome. Any ideas why I can't get this to work? Thanks! Here's the picture of the element and the HTML code.
change the xpath with //form[@jsname="GBqgNb"]//input
but if still unable to locate, try add WebDriverWait()
# wait 5 second
fileElem = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH , '//form[@jsname="GBqgNb"]//input')))
fileElem.send_keys("/path/to/file")