Collections:
Start Browser with ChromeDriver WebDriver
How to start a new browser session with ChromeDriver WebDriver server?
✍: FYIcenter.com
You can start a new browser session with ChromeDriver WebDriver 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 Collecting requests Collecting idna<2.9,>=2.5 (from requests) Collecting chardet<3.1.0,>=3.0.2 (from requests) Collecting certifi>=2017.4.17 (from requests) Installing collected packages: idna, chardet, certifi, requests Successfully installed certifi-2019.6.16 chardet-3.0.4 idna-2.8 requests-2.22.0
3. Start ChromeDriver WebDriver server with logging turned on listening on port 9515.
C:\fyicenter> \fyicenter\selenium\chromedriver\chromedriver.exe --verbose Starting ChromeDriver 75.0.3770.90 (...-refs/branch-heads/3770@{#1003}) on port 9515
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 PostSessionChrome.py # PostSessionChrome.py # Copyright (c) FYIcenter.com import requests data = """ { "capabilities": { "alwaysMatch": { "browserName": "chrome", "goog:chromeOptions": { "args": [ ], "extensions": [ ] }, "platformName": "any" }, "firstMatch": [ { } ] }, "desiredCapabilities": { "browserName": "chrome", "goog:chromeOptions": { "args": [ ], "extensions": [ ] }, "platform": "ANY", "version": "" } } """ res = requests.post("http://localhost:9515/session", data) print("Status: " + str(res.status_code)) print("Body: " + str(res.content))
5. Run the Python script:
C:\fyicenter> python PostSessionChrome.py Status: 200 Body: b'{ "value": { "capabilities": { "acceptInsecureCerts": false, "browserName": "chrome", "browserVersion": "75.0.3770.142", "chrome": { "chromedriverVersion": "75.0.3770.90 (...-refs\/branch-heads\/3770@{#1003})", "userDataDir": "C:\\Users\\fyicenter\\AppData\\Local\\Temp\\scoped_dir70244_21653" }, "goog:chromeOptions": { "debuggerAddress": "localhost:63448" }, "networkConnectionEnabled": false, "pageLoadStrategy": "normal", "platformName": "windows nt", "proxy": {}, "setWindowRect": true, "strictFileInteractability": false, "timeouts": { "implicit": 0, "pageLoad": 300000, "script": 30000 }, "unhandledPromptBehavior": "dismiss and notify" }, "sessionId": "d1e9fd4561397db9b4deb2cb5bbd0dbf" } }'
You should see that WebDriver server starts a new session with a new Chrome window started.
See the next tutorial on how load a Web page in a new session.
Â
⇒ Load Web Page in ChromeDriver WebDriver Session
⇠Start ChromeDriver WebDriver Server
⇑ WebDriver and WebDriver Servers
⇑⇑ Selenium Tutorials
2019-12-02, 1032👍, 0💬
Popular Posts:
Where to find tutorials on UFT (Unified Functional Testing) tool? I want to know how to use UFT. Her...
How to generate IPv6 Addresses? To help you to obtain some IPv6 addresses for testing purpose, FYIce...
How to generate string test values? To help you to obtain large number of string test values, FYIcen...
How to call JMeter command in a Windows batch file? I want to create a single batch job to run JMete...
How to generate email addresses? To help you to obtain some email addresses for testing purpose, FYI...