My script deals with browser automation using cURL. I need to POST user input username. I can do this by hard-coding the username like this:
# sid -> session Id
# eid -> element Id (input box here)
curl -d '{"value":["username"]}' http://localhost:9515/session/$sid/element/$eid/value
This successfully posts username but I want to read
username from user and pass this to value.
I tried:
read userName
curl -d '{"value":[$userName]}' http://localhost:9515/session/$sid/element/$eid/value
This gives me "missing command parameter" error. Passing only $userName
instead of [$userName]
gives "invalid argument: 'value' must be a list"
How do I pass a variable (userName) to the curl POST request in this case?