I am trying to play a little bit with WebDriver Protocol using Python and requests module.
I started chromedriver binary:
$ chromedriver_2.31
Starting ChromeDriver 2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8) on port 9515
Only local connections are allowed.
So far so good.
But the problem is that I get session not created exception when trying to create a session:
import requests
r = requests.post("http://127.0.0.1:9515/session", {})
print("Status: " + str(r.status_code))
print("Body: " + str(r.content))
Execution output:
Status: 200
Body: b'{"sessionId":"286421fcd381ee0471418ebce7f3e125","status":33,"value":{"message":"session not created exception: Missing or invalid capabilities\\n (Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Linux 4.4.0-91-generic x86_64)"}}'
I searched through the WebDriver Protocol docs, but I couldn't find information about which capabilities are mandatory or something like that.
So, I tried with some random capabilities:
import requests
data = {
"browserName": "chrome",
"version": "",
"platform": "LINUX",
"javascriptEnabled": "true",
"acceptInsecureCerts": "false",
"cssSelectorsEnabled": "true"
}
r = requests.post("http://127.0.0.1:9515/session", data)
print("Status: " + str(r.status_code))
print("Body: " + str(r.content))
But again fail:
Status: 400
Body: b'missing command parameters'
Do you have any ideas what is the problem and how to fix it?
UPDATE
Also tried:
import requests
data = """
{
desiredCapabilities: {
"browserName": "chrome",
"version": "",
"platform": "ANY"
}
}
"""
headers = {'Content-type': 'application/json'}
r = requests.post("http://127.0.0.1:9515/session", json=data, headers=headers)
print("Status: " + str(r.status_code))
print("Body: " + str(r.content))
Again error:
Status: 400
Body: b'missing command parameters'