Selenium.Webdriver.Chromedriver Slow to Launch - Why

Selenium.WebDriver.ChromeDriver slow to launch - why?

I have concluded that this is just how long it takes, and have come up with a way to re-use browser windows.

If you start the ChromeDriver via the overload that takes a ChromeDriverService and set EnableVerboseLogging as follows...

var service = ChromeDriverService.CreateDefaultService();
service.EnableVerboseLogging = true;

webDriver = new ChromeDriver(service, options);

... the ChromeDriver window shows verbose info on start-up, including (UNIX-style) timestamps. I'm now satisfied that the time taken to start is simply normal.

Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800}) on port 53677
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1573036834.332][INFO]: [dd05361c2fafe521ffd5fb06e6dbe7a3] COMMAND InitSession {
"capabilities": {
"firstMatch": [ {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ "--profile-directory=Default-16031ab478b34fa8838ecc0cb76b2cd1", "--user-data-dir=C:\\Users\\xxx\\AppData\\Local\\Temp\\9f19589865c44ba6aec806fbafc1b561" ]
}
} ]
},
"desiredCapabilities": {
"browserName": "chrome",
"goog:chromeOptions": {
"args": [ "--profile-directory=Default-16031ab478b34fa8838ecc0cb76b2cd1", "--user-data-dir=C:\\Users\\xxx\\AppData\\Local\\Temp\\9f19589865c44ba6aec806fbafc1b561" ]
}
}
}
[1573036834.335][INFO]: Populating Preferences file: {
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"check_default_browser": false
},
"distribution": {
"import_bookmarks": false,
"import_history": false,
"import_search_engine": false,
"make_chrome_default_for_user": false,
"skip_first_run_ui": true
},
"dns_prefetching": {
"enabled": false
},
"profile": {
"content_settings": {
"pattern_pairs": {
"https://*,*": {
"media-stream": {
"audio": "Default",
"video": "Default"
}
}
}
},
"default_content_setting_values": {
"geolocation": 1
},
"default_content_settings": {
"geolocation": 1,
"mouselock": 1,
"notifications": 1,
"popups": 1,
"ppapi-broker": 1
},
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"translate": {
"enabled": false
}
}
[1573036834.337][INFO]: Populating Local State file: {
"background_mode": {
"enabled": false
},
"ssl": {
"rev_checking": {
"enabled": false
}
}
}
[1573036834.348][INFO]: Cannot switch to US keyboard layout - some keys may be interpreted incorrectly
[1573036834.348][INFO]: Launching chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --force-fieldtrials --ignore-certificate-errors --load-extension="C:\Users\PAUL~1.SUA\AppData\Local\Temp\scoped_dir18488_412533912\internal" --log-level=0 --no-first-run --password-store=basic --profile-directory=Default-16031ab478b34fa8838ecc0cb76b2cd1 --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\xxx\AppData\Local\Temp\9f19589865c44ba6aec806fbafc1b561"

DevTools listening on ws://127.0.0.1:53680/devtools/browser/bacb830a-c373-460e-83e8-10ab7f05d6ce
[1573036834.744][DEBUG]: DevTools HTTP Request: http://localhost:53680/json/version
[1573036835.088][DEBUG]: DevTools HTTP Response: {
"Browser": "Chrome/78.0.3904.70",
"Protocol-Version": "1.3",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36",
"V8-Version": "7.8.279.17",
"WebKit-Version": "537.36 (@edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5)",
"webSocketDebuggerUrl": "ws://localhost:53680/devtools/browser/bacb830a-c373-460e-83e8-10ab7f05d6ce"
}

[1573036835.104][DEBUG]: DevTools HTTP Request: http://localhost:53680/json
[1573036835.122][DEBUG]: DevTools HTTP Response: [ {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:53680/devtools/page/C5722CC4576C0C53221985793E2EB260",
"id": "C5722CC4576C0C53221985793E2EB260",
"title": "Chrome Automation Extension",
"type": "background_page",
"url": "chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html",
"webSocketDebuggerUrl": "ws://localhost:53680/devtools/page/C5722CC4576C0C53221985793E2EB260"
}, {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:53680/devtools/page/4B8C0B4FB68B7222E5E34BB28D75A6E4",
"id": "4B8C0B4FB68B7222E5E34BB28D75A6E4",
"title": "New Tab",
"type": "page",
"url": "chrome://newtab/",
"webSocketDebuggerUrl": "ws://localhost:53680/devtools/page/4B8C0B4FB68B7222E5E34BB28D75A6E4"
} ]

[1573036835.131][DEBUG]: DevTools HTTP Request: http://localhost:53680/json
[1573036835.135][DEBUG]: DevTools HTTP Response: [ {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:53680/devtools/page/C5722CC4576C0C53221985793E2EB260",
"id": "C5722CC4576C0C53221985793E2EB260",
"title": "Chrome Automation Extension",
"type": "background_page",
"url": "chrome-extension://aapnijgdinlhnhlmodcfapnahmbfebeb/_generated_background_page.html",
"webSocketDebuggerUrl": "ws://localhost:53680/devtools/page/C5722CC4576C0C53221985793E2EB260"
}, {
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:53680/devtools/page/4B8C0B4FB68B7222E5E34BB28D75A6E4",
"id": "4B8C0B4FB68B7222E5E34BB28D75A6E4",
"title": "New Tab",
"type": "page",
"url": "chrome://newtab/",
"webSocketDebuggerUrl": "ws://localhost:53680/devtools/page/4B8C0B4FB68B7222E5E34BB28D75A6E4"
} ]

[1573036835.152][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1573036837.137][WARNING]: Timed out connecting to Chrome, retrying...
[1573036837.138][INFO]: resolved localhost to ["::1","127.0.0.1"]
[1573036839.141][DEBUG]: DevTools WebSocket Command: Log.enable (id=1) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.142][DEBUG]: DevTools WebSocket Command: DOM.getDocument (id=2) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.144][DEBUG]: DevTools WebSocket Command: Target.setAutoAttach (id=3) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"autoAttach": true,
"waitForDebuggerOnStart": false
}
[1573036839.145][DEBUG]: DevTools WebSocket Command: Page.enable (id=4) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.146][DEBUG]: DevTools WebSocket Command: Page.enable (id=5) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.146][DEBUG]: DevTools WebSocket Response: Log.enable (id=1) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.147][DEBUG]: DevTools WebSocket Response: DOM.getDocument (id=2) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"root": {
"backendNodeId": 2,
"baseURL": "chrome-search://local-ntp/local-ntp.html",
"childNodeCount": 2,
"children": [ {
"backendNodeId": 14,
"localName": "",
"nodeId": 2,
"nodeName": "html",
"nodeType": 10,
"nodeValue": "",
"parentId": 1,
"publicId": "",
"systemId": ""
}, {
"attributes": [ "lang", "en", "class", "inited" ],
"backendNodeId": 15,
"childNodeCount": 4,
"children": [ {
"backendNodeId": 16,
"localName": "",
"nodeId": 4,
"nodeName": "#comment",
"nodeType": 8,
"nodeValue": " TODO(dbeam): dir=\"ltr\"? ",
"parentId": 3
}, {
"backendNodeId": 17,
"localName": "",
"nodeId": 5,
"nodeName": "#comment",
"nodeType": 8,
"nodeValue": " Copyright 2015 The Chromium Authors. All rights reserved.\n Use of this source code is governed by a BSD-style license that can be\n found in the LICENSE file. ",
"parentId": 3
}, {
"attributes": [ ],
"backendNodeId": 18,
"childNodeCount": 24,
"localName": "head",
"nodeId": 6,
"nodeName": "HEAD",
"nodeType": 1,
"nodeValue": "",
"parentId": 3
}, {
"attributes": [ "class", "light-chip win", "style", "background: rgb(255, 255, 255); --logo-color:rgba(238,238,238,1);" ],
"backendNodeId": 19,
"childNodeCount": 21,
"localName": "body",
"nodeId": 7,
"nodeName": "BODY",
"nodeType": 1,
"nodeValue": "",
"parentId": 3
} ],
"frameId": "4B8C0B4FB68B7222E5E34BB28D75A6E4",
"localName": "html",
"nodeId": 3,
"nodeName": "HTML",
"nodeType": 1,
"nodeValue": "",
"parentId": 1
} ],
"documentURL": "chrome-search://local-ntp/local-ntp.html",
"localName": "",
"nodeId": 1,
"nodeName": "#document",
"nodeType": 9,
"nodeValue": "",
"xmlVersion": ""
}
}
[1573036839.148][DEBUG]: DevTools WebSocket Response: Target.setAutoAttach (id=3) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.148][DEBUG]: DevTools WebSocket Response: Page.enable (id=4) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.148][DEBUG]: DevTools WebSocket Response: Page.enable (id=5) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.149][DEBUG]: DevTools WebSocket Command: Runtime.enable (id=6) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.150][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"context": {
"auxData": {
"frameId": "04C2466A16DFD233FEE7E6F1A4D5B59C",
"isDefault": true,
"type": "default"
},
"id": 4,
"name": "",
"origin": "chrome-search://most-visited"
}
}
[1573036839.150][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"context": {
"auxData": {
"frameId": "B6EA84A25C9E0EFFB88946CC7606D044",
"isDefault": true,
"type": "default"
},
"id": 3,
"name": "",
"origin": "chrome-search://most-visited"
}
}
[1573036839.151][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"context": {
"auxData": {
"frameId": "BA8BAD5C705B50773F7EC3B2596AE5B7",
"isDefault": true,
"type": "default"
},
"id": 2,
"name": "",
"origin": "chrome-search://local-ntp"
}
}
[1573036839.151][DEBUG]: DevTools WebSocket Event: Runtime.executionContextCreated 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"context": {
"auxData": {
"frameId": "4B8C0B4FB68B7222E5E34BB28D75A6E4",
"isDefault": true,
"type": "default"
},
"id": 1,
"name": "",
"origin": "chrome-search://local-ntp"
}
}
[1573036839.151][DEBUG]: DevTools WebSocket Response: Runtime.enable (id=6) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.154][DEBUG]: DevTools WebSocket Command: Page.enable (id=7) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.155][DEBUG]: DevTools WebSocket Response: Page.enable (id=7) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.155][DEBUG]: DevTools WebSocket Command: Runtime.enable (id=8) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.156][DEBUG]: DevTools WebSocket Response: Runtime.enable (id=8) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {

}
[1573036839.157][DEBUG]: DevTools WebSocket Command: Runtime.evaluate (id=9) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"awaitPromise": true,
"expression": "(function() { // Copyright (c) 2012 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\n/**\n * Enum f...",
"returnByValue": true
}
[1573036839.159][DEBUG]: DevTools WebSocket Response: Runtime.evaluate (id=9) 4B8C0B4FB68B7222E5E34BB28D75A6E4 {
"result": {
"type": "object",
"value": {
"status": 0,
"value": 1
}
}
}
[1573036839.160][INFO]: [dd05361c2fafe521ffd5fb06e6dbe7a3] RESPONSE InitSession {
"capabilities": {
"acceptInsecureCerts": false,
"browserName": "chrome",
"browserVersion": "78.0.3904.70",
"chrome": {
"chromedriverVersion": "78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800})",
"userDataDir": "C:\\Users\\xxx\\AppData\\Local\\Temp\\9f19589865c44ba6aec806fbafc1b561"
},
"goog:chromeOptions": {
"debuggerAddress": "localhost:53680"
},
"networkConnectionEnabled": false,
"pageLoadStrategy": "normal",
"platformName": "windows nt",
"proxy": {

},
"setWindowRect": true,
"strictFileInteractability": false,
"timeouts": {
"implicit": 0,
"pageLoad": 300000,
"script": 30000
},
"unhandledPromptBehavior": "dismiss and notify"
},
"sessionId": "dd05361c2fafe521ffd5fb06e6dbe7a3"
}

Chromedriver is extremely slow on a specific machine using Selenium Grid and .net

I ran into a similar issue where chromedriver was slow in some machines and it turned out to be a proxy issue. Disabling "Automatically detect settings" under Chrome://settings >Change proxy settings> LAN Settings> made webdriver execute commands faster in chrome for me.

Selenium chrome driver is slow

It has nothing in common with Selenium, you need to get a snapshot of what's going on with your operating system when you launch the browser, for example using Windows Performance Monitor

Blind shot: Chrome browser is very memory intensive (you can check how much RAM it consumes using Windows Task Manager and if your machine is short on RAM it starts intensively using page file to store some memory pages to disk and since disk is much slower comparing to the RAM - you're getting inconsistent results.

The only way of effective speeding up Selenium tests is Parallel Execution via Selenium Grid or by means of your underlying unit testing framework.

Selenium chromeDriver open extremely slower than open a website in chrome browser directly

Here is the Answer for your Question:

To avoid loading certain website, you can utilize a feature of Chrome Browser by tweaking the pageLoadStrategy through DesiredCapabilities Class and set it to none as follows:

String ABC = "ABC'S URL";
String chromeDriverPath = "C:\\selenium\\chromedriver.exe" ;
System.out.println("start selenium");
File file = new File(chromeDriverPath);
System.setProperty("webdriver.chrome.driver",file.getAbsolutePath());
ChromeOptions options = new ChromeOptions();
options.addArguments("--start-maximized");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability("pageLoadStrategy", "none");
webDriver driver = new ChromeDriver(capabilities);
driver.get(ABC);

Let me know if this Answers your Question.

Selenium Request Running slow in Chrome 79

Some more details about your usecase would have helped us to debug your issue in a better way. However you need to take care of a couple of things as follows:

  • You are using chromedriver=2.41
  • Release Notes of chromedriver=2.41 clearly mentions the following :

Supports Chrome v67-69

  • Presumably you are using chrome=79.0
  • Release Notes of ChromeDriver v79.0 clearly mentions the following :

Supports Chrome version 79

  • Your Selenium Client version is unknown to us.

So there is a clear mismatch between ChromeDriver v2.41 and the Chrome Browser v79.0


Solution

Ensure that:

  • Selenium is upgraded to current levels Version 3.141.59.
  • ChromeDriver is updated to current ChromeDriver v79.0.3945.36 level.
  • Chrome is updated to current Chrome Version 79.0 level. (as per ChromeDriver v79.0 release notes)
  • Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.

tl; dr

However, there are a couple of other measures which you can incorporate to speed up the execution and you can find a couple of relevant detailed discussion in:

  • How to speed up Java Selenium Script,with minimum wait time
  • How to increase the execution speed through Selenium and Webdriver


Related Topics



Leave a reply



Submit