2

I have the following code that I am using to log-in to my grocery store online, but I cannot get the send_keys() function to work. Any ideas what I am doing wrong?

Line 34, AttributeError: 'function' object has no attribute 'send_keys'
import time
import selenium
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from webdriver_manager.chrome import ChromeDriverManager
from pathlib import Path
from selenium.common.exceptions import NoSuchElementException
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import InvalidArgumentException
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import os
import re
import shutil
import pandas as pd
import pyautogui as gui

options = selenium.webdriver.ChromeOptions()
#options.add_argument('headless')
driver = webdriver.Chrome(driver2, options=options)

driver.get("https://nourish.schnucks.com/web-ext/user/login?redirectUrl=https:%2F%2Fnourish.schnucks.com%2F")
gui.sleep(5)
element = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, '//*[@id="logonId"]'))).click
element.send_keys('email@yahoo.com')
RCarmody
  • 712
  • 1
  • 12
  • 29

1 Answers1

1

First of all click is a method. So it should have been click()

click() doesn't returns anything, hence element remains null.


Solution

Invoke send_keys() when the element is returned through WebDriverWait as follows:

WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.XPATH, '//*[@id="logonId"]'))).send_keys('email@yahoo.com')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • I can see the click resulting in the text box whenever I run it in the foreground... It shows the blue highlight and the | for typing – RCarmody Dec 21 '20 at 15:12
  • Quick question.... This is not working when I turn on the Headless browser option to put it in the background - It just shows a timeout error as if it cant find the element. Thoughts? – RCarmody Dec 21 '20 at 15:51
  • @RCarmody Seems `AttributeError: 'function' object has no attribute 'send_keys'` is resolved now and it sounds like a different question all together. Can you raise a new question with your new requirement? Stackoverflow contributors will be happy to help you out. – undetected Selenium Dec 21 '20 at 15:54