Skip to content

Instantly share code, notes, and snippets.

@prashanthrajagopal
Last active March 13, 2024 16:19
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save prashanthrajagopal/12f53e5c98385fbf50e2 to your computer and use it in GitHub Desktop.
Save prashanthrajagopal/12f53e5c98385fbf50e2 to your computer and use it in GitHub Desktop.
Run Selenium test via curl
s_id=`curl -X POST http://127.0.0.1:4444/wd/hub/session -d '{"desiredCapabilities":{"browserName":"firefox","platform":"MAC"}}'|awk -F'"' '{print $6}'`
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/url -d '{"url":"http://www.google.com"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element -d '{"using":"id","value":"gbqfq"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element/0/value -d {"value":["selenium"]}
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element -d '{"using":"id","value":"gbqfb"}'
curl -X POST http://127.0.0.1:4444/wd/hub/session/$s_id/element/1/click
curl -X DELETE http://127.0.0.1:4444/wd/hub/session/$s_id/window
@akashdktyagi
Copy link

This is good man!

@Eduardo-Morales-Alberti

Thank you!!
We remove the entire session, instead of the window.

s_id=`curl -X POST http://hub:4444/wd/hub/session -d '{"desiredCapabilities": { "browserName": "chrome", "browser": "chrome" }}'| grep "sessionId" | awk -F'"' '{print $4}'`

curl -X POST http://hub:4444/wd/hub/session/$s_id/url -d '{"url":"http://apache/en-int/examples/product"}'

curl -X DELETE http://hub:4444/wd/hub/session/$s_id

@guocity
Copy link

guocity commented Mar 13, 2024

how to run s_id in python?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment