Collections:
Start Browser with MicrosoftWebDriver Server
How to start a new browser session with MicrosoftWebDriver server?
✍: FYIcenter.com
You can start a new browser session with MicrosoftWebDriver server
using the "POST /session" service
as shown in this tutorial.
1. Make sure Python is installed:
C:\fyicenter> python --version Python 3.7.4
2. Make sure Python "requests" module is installed:
C:\fyicenter> pip install requests ...
3. Start MicrosoftWebDriver server with logging turned on listening on port 17556.
C:\fyicenter>\fyicenter\selenium\edgedriver\MicrosoftWebDriver --verbose C:\fyicenter> \fyicenter\selenium\chromedriver\chromedriver.exe --verbose [...] - Starting server... [...] - Listening on http://localhost:17556/ [...] -
4. Enter the following Python script in a separate window to start a new browser session by sending a "POST /session" request:
C:\fyicenter> type PostSessionEdge.py
# PostSessionEdge.py
# Copyright (c) FYIcenter.com
import requests
data = """
{
"capabilities": {
"alwaysMatch": {
"browserName": "edge",
"goog:chromeOptions": {
"args": [ ],
"extensions": [ ]
},
"platformName": "any"
},
"firstMatch": [ { } ]
},
"desiredCapabilities": {
"browserName": "edge",
"goog:chromeOptions": {
"args": [ ],
"extensions": [ ]
},
"platform": "ANY",
"version": ""
}
}
"""
res = requests.post("http://localhost:17556/session", data)
print("Status: " + str(res.status_code))
print("Body: " + str(res.content))
5. Run the Python script:
C:\fyicenter> python PostSessionEdge.py
Status: 200
Body: b'{
"sessionId": "936A2C88-D144-49B9-B11E-F455816E7D3A",
"status": 0,
"value": {
"browserName": "MicrosoftEdge",
"browserVersion": "42.17134.1.0",
"platformName": "windows",
"platformVersion": "10",
"takesElementScreenshot": true,
"takesScreenshot": true,
"acceptSslCerts": true,
"applicationCacheEnabled": true,
"locationContextEnabled": true,
"webStorageEnabled": true,
"InPrivate": false,
"pageLoadStrategy": "normal"
}
}'
You should see that WebDriver server starts a new session with a new Edge window started.
See the next tutorial on how load a Web page in a new session.
⇒ Load Web Page in MicrosoftWebDriver Session
⇐ Start MicrosoftWebDriver WebDriver Server
2020-02-29, 3256🔥, 0💬
Popular Posts:
How to generate currency test values? Currency test values are frequently needed in testing date and...
In what order thread groups are executed in JMeter? Thread groups, including regular "Thread Groups"...
How to perform UUDecode (Unix-to-Unix Decode)? UUEncode is Unix-to-Unix encoding used on Unix system...
How to convert hexadecimal encoded data back to binary data (or Hex to Binary Decoding)? Hex to Bina...
How to convert a date and time to a standard format? Date and time can be displayed in a number of s...