最後更新: 2017-12-19
介紹
geckodriver=Proxy for using W3C WebDriver-compatible clients(WebDriver protocol) to interact with Gecko-based browsers.
geckodriver is a separate HTTP server that is a complete remote end implementation of WebDriver
Selenium requires a driver to interface with the chosen browser(Firefox).
Diagram:
Selenium(clients) --> WebDriver protocol --> geckodriver --> Firefox remote protocol - Firefox
Install
DL:
https://github.com/mozilla/geckodriver/releases
HTTP server
* geckodriver is a separate HTTP server that is a complete remote end implementation of WebDriver
* geckodriver is written in Rust, a systems programming language from Mozilla.
# Connecting to an existing Firefox instance. The instance must have Marionette enabled.
# logging verbosity -v[v]
# Default: --host 127.0.0.1
geckodriver -v --host 192.168.88.122 --connect-existing --marionette-port 2828
# -d: POST Data
curl -d '{"capabilities": {"alwaysMatch": {"acceptInsecureCerts": true}}}' http://192.168.88.122:4444/session
{"value": {"sessionId":"a0dc7155-0d1c-4c3d-ba5b-715a441d5331", ...}
# CMD
curl http://192.168.88.122:4444/session/a0dc7155-0d1c-4c3d-ba5b-715a441d5331/url
{"value":"about:home"}
# -X: specified request will be used
curl -X DELETE http://192.168.88.122:4444/session/a0dc7155-0d1c-4c3d-ba5b-715a441d5331
{"value": {}}
curl http://192.168.88.122:4444/session/a0dc7155-0d1c-4c3d-ba5b-715a441d5331/url
{"value":{"error":"session not created", ...}
List of Endpoints
Method: POST, GET, DELETE
/status # GET
curl -sS http://192.168.88.122:4444/status | jq .
{ "value": { "message": "Session already started", "ready": false } }
/session # POST