mozilla / geckodriver

WebDriver for Firefox
https://firefox-source-docs.mozilla.org/testing/geckodriver/
Mozilla Public License 2.0
7.14k stars 1.52k forks source link

send_key() throws exception #1133

Closed bksh05 closed 6 years ago

bksh05 commented 6 years ago

System

code

import unittest
from selenium import webdriver
import time
from selenium.webdriver.common.keys import Keys

class PythonOrgSearch(unittest.TestCase):

    def setUp(self):
        self.driver = webdriver.Firefox()

    def test_search_in_python_org(self):
        driver = self.driver
        driver.get("http://www.google.com")

        elem = driver.find_element_by_id("lst-ib")
        elem.send_keys("pycon")
        elem.send_keys(Keys.RETURN)
        assert "No results found." not in driver.page_source

    def tearDown(self):
        self.driver.close()

if __name__ == "__main__":
    unittest.main()

Tracelog

Traceback (most recent call last): File "example.py", line 18, in test_search_in_python_org elem.send_keys("pycon") File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 479, in send_keys 'value': keys_to_typing(value)}) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webelement.py", line 628, in _execute return self._parent.execute(command, params) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute self.error_handler.check_response(response) File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 237, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.InvalidArgumentException: Message: Expected [object Undefined] undefined to be a string

HelioGuilherme66 commented 6 years ago

No problems on my Fedora 26, stock Python 3.6.3, Version: 0.19.1 Platform: Linux Firefox: 57.0.4 Selenium: 3.8.1

bksh05 commented 6 years ago

I use ubuntu 16.04 And it throws this exception

whimboo commented 6 years ago

As requested when filing an issue, there is no trace level log attached. Please consult https://firefox-source-docs.mozilla.org/testing/geckodriver/geckodriver/TraceLogs.html in how to get that.

bksh05 commented 6 years ago

I have included log file Is it okay??

1516216877452   geckodriver INFO    Listening on 127.0.0.1:59701
1516216878456   mozprofile::profile INFO    Using profile path /tmp/rust_mozprofile.idDSRXavISpv
1516216878459   geckodriver::marionette INFO    Starting browser /usr/bin/firefox
1516216878464   geckodriver::marionette INFO    Connecting to Marionette on localhost:35275
1516216879304   Marionette  INFO    Enabled via --marionette
1516216882199   Marionette  INFO    Listening on port 35275
1516216882443   Marionette  DEBUG   Register listener.js for window 2147483649
1516216882469   Marionette  DEBUG   Received DOM event "beforeunload" for "about:blank"
1516216883816   Marionette  DEBUG   Received DOM event "pagehide" for "about:blank"
1516216883817   Marionette  DEBUG   Received DOM event "unload" for "about:blank"
1516216884109   Marionette  DEBUG   Received DOM event "DOMContentLoaded" for "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=MqJfWpLvKpCh8wfvjYCoAQ&gws_rd=ssl"

(firefox:7519): GLib-GObject-WARNING **: /build/glib2.0-prJhLS/glib2.0-2.48.2/./gobject/gsignal.c:3486: signal name 'selection_changed' is invalid for instance '0x7fbc376eeb00' of type 'MaiAtkType139'
1516216885571   Marionette  DEBUG   Received DOM event "pageshow" for "https://www.google.co.in/?gfe_rd=cr&dcr=0&ei=MqJfWpLvKpCh8wfvjYCoAQ&gws_rd=ssl"
JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 324: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]
JavaScript error: jar:file:///usr/lib/firefox/omni.ja!/components/nsUrlClassifierListManager.js, line 324: NS_ERROR_NOT_INITIALIZED: Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIUrlClassifierDBService.getTables]
whimboo commented 6 years ago

This is not a trace level log, and if you check those lines you won't find any errors/exceptions listed. So please get a trace log, and make sure that the failure you are referring to is visible. Thanks.

bksh05 commented 6 years ago

Sorry actually i am new to this I will upload the tracelog soon

ameliavoncat commented 6 years ago

I'm getting this same issue whenever I use send_keys.

macOS 10.12.6
Firefox 57.0.4
selenium 3.8.1
geckodriver 0.19.1
python 2.7.10

Here is the relevant part of my trace log:

1516658077669   webdriver::server   DEBUG   Got request POST AbsolutePath("/session/374558f1-3025-9b4d-9020-c4ae90c10d45/element/c5cf84c2-f0d6-6542-9339-34b0f95a4027/value")
1516658077669   webdriver::command  DEBUG   Got request body {"text": "testbot", "sessionId": "374558f1-3025-9b4d-9020-c4ae90c10d45", "id": "c5cf84c2-f0d6-6542-9339-34b0f95a4027", "value": ["t", "e", "s", "t", "b", "o", "t"]}
1516658077669   geckodriver::marionette DEBUG   → 110:[0,18,"sendKeysToElement",{"id":"c5cf84c2-f0d6-6542-9339-34b0f95a4027","value":["t","e","s","t","b","o","t"]}]
1516658077670   Marionette  TRACE   0 -> [0,18,"sendKeysToElement",{"id":"c5cf84c2-f0d6-6542-9339-34b0f95a4027","value":["t","e","s","t","b","o","t"]}]
1516658077670   Marionette  TRACE   0 <- [1,18,{"error":"invalid argument","message":"Expected [object Undefined] undefined to be a string","stacktrace":"WebDriverError@chrome://marionette/content/error.js:235:5\nInvalidArgumentError@chrome://marionette/content/error.js:362:5\nassert.that/<@chrome://marionette/content/assert.js:384:13\nassert.string@chrome://marionette/content/assert.js:294:10\nGeckoDriver.prototype.sendKeysToElement@chrome://marionette/content/driver.js:2545:3\ndespatch@chrome://marionette/content/server.js:553:20\nexecute@chrome://marionette/content/server.js:527:11\nonPacket/<@chrome://marionette/content/server.js:502:15\nonPacket@chrome://marionette/content/server.js:501:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:501:9\n"},null]
1516658077671   geckodriver::marionette DEBUG   ← [1,18,{"error":"invalid argument","message":"Expected [object Undefined] undefined to be a string","stacktrace":"WebDriverError@chrome://marionette/content/error.js:235:5\nInvalidArgumentError@chrome://marionette/content/error.js:362:5\nassert.that/<@chrome://marionette/content/assert.js:384:13\nassert.string@chrome://marionette/content/assert.js:294:10\nGeckoDriver.prototype.sendKeysToElement@chrome://marionette/content/driver.js:2545:3\ndespatch@chrome://marionette/content/server.js:553:20\nexecute@chrome://marionette/content/server.js:527:11\nonPacket/<@chrome://marionette/content/server.js:502:15\nonPacket@chrome://marionette/content/server.js:501:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:501:9\n"},null]
1516658077671   webdriver::server   DEBUG   Returning status BadRequest
1516658077671   webdriver::server   DEBUG   Returning body {"error":"invalid argument","message":"Expected [object Undefined] undefined to be a string"}
1516658077671   hyper::header   TRACE   Headers.set( "Content-Type", ContentType(Mime(Application, Json, [])) )
1516658077671   hyper::header   TRACE   Headers.set( "Content-Length", ContentLength(93) )
1516658077671   hyper::server::response DEBUG   writing head: Http11 BadRequest
1516658077671   hyper::header   TRACE   Headers.set( "Date", Date(HttpDate(Tm { tm_sec: 37, tm_min: 54, tm_hour: 21, tm_mday: 22, tm_mon: 0, tm_year: 118, tm_wday: 1, tm_yday: 21, tm_isdst: 0, tm_utcoff: 0, tm_nsec: 671501000 })) )
1516658077671   hyper::server::response DEBUG   headers [
Headers { Content-Type: application/json, Content-Length: 93, Connection: close, Date: Mon, 22 Jan 2018 21:54:37 GMT, }]
1516658077671   hyper::server::response DEBUG   write 93 bytes
1516658077671   hyper::server::response TRACE   ending
1516658077671   hyper::server   DEBUG   keep_alive = false for 127.0.0.1:60159
1516658077671   hyper::server   DEBUG   keep_alive loop ending for 127.0.0.1:60159
whimboo commented 6 years ago

@ameliavoncat this is very strange. Especially when I check this line:

[0,18,"sendKeysToElement",{"id":"c5cf84c2-f0d6-6542-9339-34b0f95a4027","value":["t","e","s","t","b","o","t"]}]

Here the content is getting send as value but not text. Via the WebDriver spec only text is supported. And here it is null. Please try to upgrade your Selenium binding, and if the problem still persists, file an issue appropriately for that other project. It's not a problem on our side as I can see so far. @andreastt maybe you can have a second look at it?

whimboo commented 6 years ago

Btw. interesting here is that everyone affected by this problem is using Selenium 3.8.1.

whimboo commented 6 years ago

Oh, I was wrong. The split for value and text is happing in geckodriver. Given that this is not visible for you all means that you are not using the latest release of geckodriver. So please upgrade to 0.19.1 and it should work.

@bksh05 make sure you check the same.

I will close this issue for now. It can be reopened in case there is a real problem with 0.19.1 and a trace log attached.

whimboo commented 6 years ago

@MukulMux first please do not high-jack other issues but please file your own one. Second, by using chromedriver this is the wrong issue tracker. This is about geckodriver.