mozilla / geckodriver

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

moz/addon/install not success #2177

Closed StarXXin closed 2 months ago

StarXXin commented 2 months ago

System

Testcase

POST /session/{session id}/moz/addon/install to install an extension [Gecko only] request Body: {"path": "base64('a.xpi')", "temporary":true}

Stacktrace

{ "value": { "error": "unknown error", "message": "Expected absolute path: [Exception... \"Component returned failure code: 0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH) [nsIFile.initWithPath]\" nsresult: \"0x80520001 (NS_ERROR_FILE_UNRECOGNIZED_PATH)\" location: \"JS frame :: chrome://remote/content/marionette/addon.sys.mjs :: install :: line 72\" data: no]", "stacktrace": "RemoteError@chrome://remote/content/shared/RemoteError.sys.mjs:8:8\nWebDriverError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:192:5\nUnknownError@chrome://remote/content/shared/webdriver/Errors.sys.mjs:816:5\ninstall@chrome://remote/content/marionette/addon.sys.mjs:74:13\nGeckoDriver.prototype.installAddon@chrome://remote/content/marionette/driver.sys.mjs:2954:21\ndespatch@chrome://remote/content/marionette/server.sys.mjs:318:40\nexecute@chrome://remote/content/marionette/server.sys.mjs:289:16\nonPacket/<@chrome://remote/content/marionette/server.sys.mjs:262:20\nonPacket@chrome://remote/content/marionette/server.sys.mjs:263:9\n_onJSONObjectReady/<@chrome://remote/content/marionette/transport.sys.mjs:494:20\n" } }

Trace-level log

whimboo commented 2 months ago

Whether you are using a local path to the XPI file, which as best should be absolute, or you have to read the contents of the XPI file first before calling base64 related methods.

Note that the above just assumes that the path to the XPI is base64('a.xpi').

StarXXin commented 2 months ago

Yes, I am using an absolute path xx. xpi (D: \ xx. xpi) file. I would like to know how to pass the value of path in the request parameters {"path": "", "temporary": true} for the POST/session/{session id}/moz/add/install method. I have obtained the value corresponding to the path through this method now. Extension_zip_path='D: \ \ xx. xpi ' Profile=Firefox Profile() Profile. add_extension (extension_zip_path) Driver=webdriver Remote (command_executor=command_executor, desired capabilities=capabilities, options=options, profile=profile) Then take out functionalities. get ('alwaysMatch '). get ('moz: firefoxOptions'). get ('pfofile') and assign it to the path

whimboo commented 2 months ago

Please create a trace log given that I do not know how Selenium constructs specific commands for the profile setup.