How do you automatically open the Chrome Devtools tab within Selenium (C#)?

selenium open developer tools chrome
how to access network panel on google chrome developer tools with selenium?
chrome developer tools extension
selenium chrome dev tools makes a perfect browser automation recipe
chrome dev tools open on new tab
how to enable developer tools in chrome
chrome open window with dev tools
chrome devtools protocol java

I see that there's a relatively new option to open Chrome with Devtools open from the command line, which I have gotten to work from my Windows 8.1 command line using a call like this:

c:\Program Files (x86)\Google\Chrome\Application>"chrome.exe" --auto-open-devtools-for-tabs

When I try to add this option on the same box when creating my ChromeDriver in Selenium (in C#), however, the option seems to be ignored.

var options = new ChromeOptions();
options.AddArgument("auto-open-devtools-for-tabs");

string executingAssembly = System.Reflection.Assembly.GetExecutingAssembly().Location;
string driverPath = Path.Combine(Path.GetDirectoryName(executingAssembly), "ChromeWebDriver");
_driver = new ChromeDriver(driverPath, options);

I've tried a few variations on theme to make sure options are working at all, including...

var options = new ChromeOptions();
options.AddArguments(new[] { "start-maximized", "auto-open-devtools-for-tabs"});

... and...

var options = new ChromeOptions();
options.AddArgument("start-maximized");
options.AddArgument("auto-open-devtools-for-tabs");

... and...

var options = new ChromeOptions();
options.AddArgument("start-maximized");
options.AddExcludedArgument("auto-open-devtools-for-tabs");

... as well as setting those with -- in front of each option string. All I get from any of those are maximized windows.

I get the feeling the auto-open-devtools-for-tabs argument's not supported by Selenium's Chrome Web Driver, but I'm not sure why that wouldn't support the same set of options as the "full" app.

Anyone have this option working with Selenium in C#, or know why it shouldn't be working in this case?


This is not unlike this question, but here I'm asking specifically about the auto-open-devtools-for-tabs option with C#. That asker claims not to have had any luck with options, and was asking how to open devtools from "within" Selenium, looking for a method explicitly before this option existed.

I've tried this with in VS 2017, Selenium v3.12.1#, Firefox v60.0.2, Chrome v66, Nunit v3.10.1, Gecko Driver v20.1, and Chrome driver v2.4 (all using C#).

I tried to search for Firefox but did not have any success. I did find a solution for Chrome v66.

Please provide profile like this: options.AddArguments("--auto-open-devtools-for-tabs");

This is a complete chrome driver implementation:

ChromeOptions options = new ChromeOptions();
options.AddArgument("--start-maximized");
options.AddArguments("disable-infobars");
options.AddArguments("--disable-notifications");
options.AddArguments("--auto-open-devtools-for-tabs");
driver = new ChromeDriver(DrivePath, options, TimeSpan.FromSeconds(100));

See also this post: "List of Chromium Command Line Switches"

Below commands are NOT working, this is issue with Geckodriver so Gecko team has to provide some solution or fix for that:

driver.FindElement(By.CssSelector("body")).SendKeys(Keys.F12);

Actions action = new Actions(driver); action.SendKeys(Keys.F12); action.Perform();

Actions action = new Actions(driver); action .KeyDown(Keys.Control)
    .SendKeys(Keys.F12).KeyUp(Keys.Control).Perform();

Actions action = new Actions(driver); action.SendKeys(Keys.F12); action.Click();

Open devtools when running a Selenium Chrome test, How do you automatically open the Chrome Devtools tab within Selenium (C#)? AddUserProfilePreference("auto-open-devtools-for-tabs", "true"); I've tried this with in VS 2017, Selenium v3.12.1#, Firefox v60.0.2, Chrome v66, Nunit v3.​10.1, Gecko Driver v20.1, and Chrome driver v2.4 (all using C#). I see that there's a relatively new option to open Chrome with Devtools open from the command line, which I have gotten to work from my Windows 8.1 command line using a call like this: c:\Program

Following the thread on SO-12212504 and leading from the selected answer.

One of the solution to this would be pressing F-12 [Key F12 Documentation] key using :

// without an element
new Actions(driver).SendKeys(Keys.F12).Perform();

// send keys to body
new Actions(driver).SendKeys(driver.FindElement(By.XPath("//body")), Keys.F12).Perform();

On the other side could you try and use AddUserProfilePreference from amongst the ChromeOptions Methods :

ChromeOptions options = new ChromeOptions();
options.AddUserProfilePreference("auto-open-devtools-for-tabs", "true");

Note : I am not very sure about the parameter name, but I hope you can find something corresponding here.


Edit : Some more attempts using keyboard shortcuts for the same -

Windows : [F12 or Ctrl + Shift + I]

String openDevTools = Keys.chord(Keys.CONTROL, Keys.SHIFT, "I");
driver.FindElement(By.XPath("//body")).SendKeys(openDevTools).Perform();

Mac : [Cmd + Opt + I]

String openDevTools = Keys.chord(Keys.COMMAND, Keys.ALT, "I");
driver.FindElement(By.XPath("//body")).SendKeys(openDevTools).Perform();

Open Chrome DevTools | Tools for Web Developers, How do you automatically open the Chrome Devtools tab within Selenium (C#)? - google-chrome. I see that there's a relatively new option to open Chrome with  I am looking to access/use Chrome's devtools panel with Selenium Webdriver. Specifically, I want to use the "WASP" chrome plugin, which is accessed through devtools. I've got my selenium set up to run with the WASP plugin included, and I can open DevTools (with sendKeys.F12), but I don't know how to actually use that panel now that it is open.

Ruby: must have installed latest selenium-webdriver (3.7.0) gem

options1 = Selenium::WebDriver::Chrome::Options.new

options1.add_argument('--auto-open-devtools-for-tabs')

driver = Selenium::WebDriver.for :chrome, options: options1

driver.get("https://stackoverflow.com")

Selenium Tutorial: User Interactions, The Network tab in Chrome devtools doesn't record requests unless open though with the the chrome option --auto-open-devtools-for-tabs . Open the last panel you had open. Press Command+Option+I (Mac) or Control+Shift+I. Open DevTools from Chrome's main menu. Click Customize and control Google Chrome and then select More Tools > Developer Tools. Figure 2. Opening DevTools from Chrome's main menu Auto-open DevTools on every new tab

Jak automatycznie otworzyć zakładkę Chrome DevTools w selen, All of the ways that you can open Chrome DevTools. DevTools from Chrome's main menu; Auto-open DevTools on every new tab Or press Command + Option + C (Mac) or Control + Shift + C (Windows, Linux, Chrome OS). Except as otherwise noted, the content of this page is licensed under the  You can use the LoggingPreferences to get the Performance logs. It returns the data in json format. Here is a sample java code. Tested this with selenium 2.53, chromedriver 2.20, Chrome 50 on Ubuntu 14.04. This should work on windows also.

How to Inspect Elements with Chrome Developer Tools?, In this video, we are going to learn how to open developer tools in this user interactions in Duration: 5:28 Posted: Feb 15, 2017 Learn how to Open Chrome Browser selenium C# webdriver on Visual Studio.

Selenium WebDriver Using Chrome WebDriver in Visual Studio C, Jak automatycznie otworzyć zakładkę Chrome DevTools w selen (C #)?. głosy AddUserProfilePreference("auto-open-devtools-for-tabs", "true"); driver = Selenium::WebDriver.for :chrome, options: options1 driver.get("https://​stackoverflow.com") Gecko Kierowca v20.1 i Chrome kierowca v2.4 (wszystko za pomocą C #). the fact that it is designed specifically for testing put me off - not only do you have to control Chrome through a secondary executable (chromedriver.exe), but in recent versions of Chrome there is a message appearing on top of the screen warning the user that Chrome is controlled by automated testing software.

Comments
  • No dice on AddUserProfilePreference. Worth a shot; thanks. But no devtools when I run it, same as before. And though it's a different route, I did try SendKeys, but it only opened devtools intermittently. Worse, the times it does work, I get kinda what I thought I might, disconnected: received Inspector.detached event\n (Session info: chrome=50.0.2661.102) (Driver info: chromedriver=2.21.371459... So no luck yet.
  • Oh okay, probably the flag auto-open-devtools-for-tabs shall exist just the way to use it is not documented anywhere. stackoverflow.com/a/36957422/1746118