Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97785

selenium 'nonetype' object has no attribute 'send_keys'

$
0
0
title='this is the title'

I want to locate with python/selenium, within a web page, this line:

<input id="subject" name="subject" maxlength="50" value="" class="nude error" type="text">

I use this code with python-selenium (under Debian):

title = driver.find_element_by_id("subject").clear()
title.send_keys(title) 

I got the following error:

Traceback (most recent call last):

  File "./basic0", line 49, in <module>
titre.send_keys(title)

AttributeError: 'NoneType' object has no attribute 'send_keys'

note:when the script stops because of this error, the mouse cursor is at the right at place within the web page; but I cannot find a way to send_keys to fill in the input

I also tried:

title = driver.find_element_by_xpath("div[contains(text(),'subject')]")

title = driver.find_element_by_xpath("//form[input/@id='subject']")

title = driver.find_element_by_xpath("//form[input[@name='subject']")

but it does not work; furthermore the mouse cursor is not at the right place.

then I tried a later selenium version:

I completly purge python-selenium package under Debian (which is selenium v. 2.53) then

pip install selenium==3.3.1

This time, when I launch the script it says that geckodriver is missing: so,

wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux32.tar.gz

tar -xvzf geckodriver-v0.23.0-linux32.tar.gz

chmod 755 geckodriver (I also tried 777)

mv geckodriver /usr/local/bin/ (so it's in my PATH)

now when I launch the script, here is the error message I got:

Traceback (most recent call last):

  File "./basic0", line 13, in <module>
driver = webdriver.Firefox()

  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 155, in __init__
keep_alive=True)

  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)

  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)

  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 238, in execute
self.error_handler.check_response(response)

  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
raise exception_class(message, screen, stacktrace)

selenium.common.exceptions.WebDriverException: Message: connection refuse

firefox window pops-up, and then shutdown when the script stops


Viewing all articles
Browse latest Browse all 97785

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>