[🐛 Bug]: GetDevToolsSession in WPF hangs forever
See original GitHub issueWhat happened?
GetDevToolsSession in WPF Application hangs forever, but same code in Console Application work fine.
How can we reproduce the issue?
MainWindow.xaml:
<Button Content="Just Click" Click="Button_Click"></Button>
MainWindow.xaml.cs:
private void Button_Click(object sender, RoutedEventArgs e)
{
IWebDriver driver = new ChromeDriver();
IDevTools devTools = driver as IDevTools;
DevToolsSession session = devTools.GetDevToolsSession(); //this line never return
driver.Navigate().GoToUrl("https://bing.com");
driver.Quit();
}
Relevant log output
no relevant log output and vs2019 hasn't error log
Operating System
windows 10
Selenium version
.net c# 4.0.1
What are the browser(s) and version(s) where you see this issue?
chrome 95.0.4638.69
What are the browser driver(s) and version(s) where you see this issue?
ChromeDriver 95.0.4638.5401
Are you using Selenium Grid?
no
Issue Analytics
- State:
- Created 2 years ago
- Comments:7
Top Results From Across the Web
Visual Studio Hangs in WPF Design View - ".NET Runtime ...
I ended up running the following to get a stack trace of Visual Studio when it was hanging: adplus -hang -pn devenv.exe.
Read more >Accept micro-donations through Zink - Zedeus/Nitter - IssueHint
Stripe for example takes .25€ per transaction so is there some amount you ... [🐛 Bug]: GetDevToolsSession in WPF hangs forever, 7, 2021-11-03,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
do this :
DevToolsSession session; private void Button_Click(object sender, RoutedEventArgs e) { IWebDriver driver = new ChromeDriver(); IDevTools devTools = driver as IDevTools; Task.Run(() => { session = devTools.GetDevToolsSession(); }); driver.Navigate().GoToUrl(“https://bing.com”); driver.Quit(); }
I was also facing the same issue in my project. I don’t think that app type is the problem there, the issue is the context within which you are trying to get the session with
DevToolsSession session = devTools.GetDevToolsSession();
. Let me explain it on my example. Background I have a custom web testing framework which consist of 2 projects - Web tests project [UITests] + Selenium project [Core]. UITests is the place where I store all the tests written with Specflow library, page objects, steps implementation and all stuff related to the System Under Test [SUT]. Core is the main framework shareable between different SUT projects, it contains common logic such as WebDriver configuration and implementation, additional helper methods etc, not related to any particular SUT.Problem As by following good coding practices, I wanted to put session initialization inside my Core project, so then it can be reusable across other projects. Because of that, I’ve initially placed the GetDevToolsSession() method call in main class responsible for handling WebDriver. Unfortunately it’s a part of the Core project, so I was getting the same issue as described by OP, the code was just freezing without any error.
Solution For me, the solution to that problem was just simply placing GetDevToolsSession() call inside the project I originally use for running the tests, which was UITests project. I assume if all the above examples are related to multi-project solutions, then probably you’re trying to call GetDevToolsSession() inside non-executable namespace, so maybe some external library project, which for selenium is a separate context for some reason. Guess this is a bug as I can easily create new driver instance, regardless the namespace or project I’m in.