Python Forum

Full Version: Python 3/selenium - nontype error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
hopefully someone can help me understand why I am getting the below error --


with this code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Firefox()
driver.get("<URL>")
search=driver.find_element(By.XPATH, '<xpath>').click()
search_box=driver.find_element(By.XPATH, '<xpath>').click()
search_box.send_keys("trial")


I am getting this error:

search_box.send_keys("trial")
AttributeError: 'NoneType' object has no attribute 'send_keys'
Please edit your post and use the code tags (Insert Python).
The error is showing that the search_box variable is getting None from click().
search_box=driver.find_element(By.XPATH, '<xpath>').click()
try with below code

driver.find_element(By.XPATH, '<xpath>').send_keys("trial")
or
search_box = driver.find_element(By.XPATH, '<xpath>')
search_box.click()
search_box.send_keys("trial")