Skip to content
This repository was archived by the owner on Nov 29, 2018. It is now read-only.

On python, upload file is Unrecognized command #3736

Closed
lukeis opened this issue Mar 3, 2016 · 16 comments
Closed

On python, upload file is Unrecognized command #3736

lukeis opened this issue Mar 3, 2016 · 16 comments

Comments

@lukeis
Copy link
Member

lukeis commented Mar 3, 2016

Originally reported on Google Code with ID 3736

After updating to python-selenium 2.21, we started getting an error while uploading
a file on the Selenium Simple Test self test.

Attached is the script that exposes the problem.

This is the error:
Traceback (most recent call last):
  File "test.py", line 8, in <module>
    file_input.send_keys(file_path)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py",
line 143, in send_keys
    value = self._upload(local_file)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py",
line 219, in _upload
    return self._execute(Command.UPLOAD_FILE, {'file': base64.encodestring(fp.getvalue())})['value']
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py",
line 204, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 153, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py",
line 125, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: 'Unrecognized command: POST
/session/ed135e3e-cc23-419e-ab09-c29b2fead6f6/file'

Reported by leo.lathspell on 2012-04-16 16:19:07


- _Attachment: [test.py](https://storage.googleapis.com/google-code-attachments/selenium/issue-3736/comment-0/test.py)_
@lukeis lukeis self-assigned this Mar 3, 2016
@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

same thing happens with chrome (and i'd assume IE too). I'm not sure why this endpoint
was added to the python code... I can't see it anywhere in the JSONWireProtocol

Reported by luke.semerau on 2012-04-16 16:30:19

  • Status changed: Accepted
  • Labels added: Priority-High, Lang-Python
  • Labels removed: Priority-Medium

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This issue was closed by revision r16627.

Reported by david.burns@theautomatedtester.co.uk on 2012-04-16 20:02:37

  • Status changed: Fixed

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

it's not fixed. i have 2.21.2 and still see the same issue.

Reported by diana.tzinov@beatport.com on 2012-04-25 21:32:48

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

The fix is almost there - it needs another conditional because the Message can be different
from "Unrecognised command: POST".  It can also be "Command not found: POST".  If you
hack the remote driver and add this conditional to the change made by David, it all
works.

Reported by bithir on 2012-04-26 10:22:41

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

can someone suggest where this is broken since the group who raised it have it working.

I am sure that you can appreciate that "it's not fixed" is not a bug report, not even
in the slightest, and therefore can not be acted on.

status will stay as is until more info is given

Reported by david.burns@theautomatedtester.co.uk on 2012-04-28 10:11:38

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

When running it in our project, the same stack trace as above, however, message was
slightly different.  Instead of the "Unrecognised command", it was "Command not found:
POST".

All I did to remedy this, was in the local source of our selenium add this condition
to the change you did and it works for us.  I.e. where you in diff r16627 line 223
do:
if "Unrecognized command: POST" in e.__str__():

we also now check for "Command not found: POST".

Reported by bithir on 2012-04-28 11:32:13

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

unfortunately only the original person to raise this bug has given anything meaningful.
Adding random strings to code is not something I would ever do as this is a Bad Idea.


Until I can get something like a browser and Version or browser and OS, that returns
this message that you are suggesting then unfortunately this bug will not be looked
at again.

status will stay as is until more info is given

Reported by david.burns@theautomatedtester.co.uk on 2012-04-28 14:18:12

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Fair enough - I am not to concerned, I already changed the code to work in our scenario,
based upon your fix.  

Our machines are in a secure network, so just getting a stack trace from there takes
a long time and you have to jump through big hurdles signing papers to move any data
from them.  I just tried to be helpful for the others that are experiencing similar,
possible the same, problem.

Reported by bithir on 2012-04-28 14:27:57

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Unfortunately nothing helpful has been given in my opinion. "Add this random string
and it works" doesn't tell me what OS, Browser or what you are trying to work around.


Since this bug has STR for the bug that is fixed I can't see why you can't tell me
basic information. Think of it this way, would you accept a random telling you "Add
this random string" in a bug report from one of your clients? 


Reported by david.burns@theautomatedtester.co.uk on 2012-04-28 15:14:08

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

As I said earlier, the stack trace is exactly the same as above, bar the different original
python file, GUID and the message in the WebDriverException.

I.e - without having signed the paper
  File "OurPyTest.py", line X, in <module>
    file_input.send_keys(file_path)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py",
line 143, in send_keys
    value = self._upload(local_file)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py",
line 219, in _upload
    return self._execute(Command.UPLOAD_FILE, {'file': base64.encodestring(fp.getvalue())})['value']
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webelement.py",
line 204, in _execute
    return self._parent.execute(command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py",
line 153, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/errorhandler.py",
line 125, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: 'Command not found: POST /session/<guid>/file'

Os: XP, Webbrowser: IE6, Python version: 2.7, Unsure which Selenimum version it is,
but it contains the fix in r16627.  Not looked into what generates the WebDriverException
message and as such I do not know if it is related to the type WedDriver or not.

Reported by bithir on 2012-04-28 15:24:58

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Knowing the OS and the browser is all I needed. I will make sure that it is fixed asap
then.

Reported by david.burns@theautomatedtester.co.uk on 2012-04-28 15:27:15

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

I got a different message from above mentioned, ie. 'status":405,"value":["GET","HEAD","DELETE"]'.
And I add the extra condition check and it works.

Reported by ryan.nieh on 2012-05-05 03:17:40

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

@ryan please let us know what browser, browser version and platform you were running
against

Reported by luke.semerau on 2012-05-05 03:36:39

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

This was fixed in r16800.

Please in future add browser, browser version and platform as a MINIMUM to bug reports.
The bug report without that is pretty much invalid and could be closed as invalid or
even worse, ignored.

Reported by david.burns@theautomatedtester.co.uk on 2012-05-05 07:31:24

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

@luke, the browser I used for the test was Google Chrome, build 18.0.1025.168 on Windows
7. 

Reported by ryan.nieh on 2012-05-07 08:26:03

@lukeis
Copy link
Member Author

lukeis commented Mar 3, 2016

Reported by luke.semerau on 2015-09-17 18:15:16

  • Labels added: Restrict-AddIssueComment-Commit

@lukeis lukeis closed this as completed Mar 3, 2016
@SeleniumHQ SeleniumHQ locked and limited conversation to collaborators Mar 4, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant