Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3/selenium - nontype error
#1
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'
Reply
#2
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()
Reply
#3
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")
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Selenium weird error julio2000 0 1,669 Feb-23-2020, 01:24 PM
Last Post: julio2000
  Selenium webdriver error WiPi 4 12,096 Feb-09-2020, 11:38 AM
Last Post: WiPi
  error when running headless selenium julio2000 2 4,559 Feb-01-2020, 12:41 PM
Last Post: julio2000
  Error clicking button with selenium julio2000 4 5,341 Jan-06-2020, 10:59 AM
Last Post: julio2000
  Selenium error with ebdriver (geckodriver) Martinelli 4 4,722 Sep-24-2019, 01:40 AM
Last Post: Martinelli
  Python Selenium .click() Loads Error - Works Manually.- Events not Triggered NSearch 24 11,752 Aug-14-2019, 02:23 PM
Last Post: NSearch
  Error when trying to use Selenium ejected 1 5,180 Mar-26-2019, 04:53 AM
Last Post: ejected
  Instagramlogin Error (Selenium) julian_veit 0 2,635 Jan-26-2019, 02:40 PM
Last Post: julian_veit
  selenium error : evilcode1 7 5,164 Nov-12-2018, 01:08 PM
Last Post: snippsat
  Getting error when accessing elements in a modal window of an webpage using selenium sumandas89 3 8,654 Jul-13-2018, 10:44 AM
Last Post: mlieqo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020