Unable to bind cefsharp with selenium chromedriver

80 views
Skip to first unread message

rd seeker

unread,
Feb 14, 2023, 11:35:10 PM2/14/23
to CefSharp
Using below code i was able to bind cefglue client with Selenium Chrome Driver. But it doesn't works for cefsharp.

Imports OpenQA.Selenium.Chrome
Imports System.Threading
Imports OpenQA.Selenium
Imports OpenQA.Selenium.Support.Events
Imports OpenQA.Selenium.Support.Extensions
Imports OpenQA.Selenium.Support.PageObjects
Imports OpenQA.Selenium.Support.UI

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Try


            Dim service = ChromeDriverService.CreateDefaultService("D:\chromedriver_win32")
            Dim chromeOptions As New OpenQA.Selenium.Chrome.ChromeOptions()
            chromeOptions.BinaryLocation() = "D:\cefsharp\net452\CefSharp.MinimalExample.WinForms.exe"

            chromeOptions.AddExcludedArgument("ignore-certifcate-errors")
            chromeOptions.AddArgument("test-type")
            chromeOptions.AddArgument("--allow-insecure-localhost")
            chromeOptions.AddArguments("start-maximized") ' open Browser In maximized mode
            chromeOptions.AddArguments("disable-infobars") ' disabling infobars
            chromeOptions.AddArguments("--disable-extensions") ' disabling extensions
            chromeOptions.AddArguments("--disable-gpu") ' applicable To windows os only
            chromeOptions.AddArguments("--disable-dev-shm-usage") ' overcome limited resource problems
            chromeOptions.AddArgument("--remote-debugging-port=20480")
            chromeOptions.AddArguments("--disable-dev-shm-usage")
       
            Dim driver As OpenQA.Selenium.Chrome.ChromeDriver = New OpenQA.Selenium.Chrome.ChromeDriver(service, chromeOptions, TimeSpan.FromSeconds(120))
            driver.Navigate().GoToUrl("https://chromedriver.chromium.org/downloads")
            Thread.Sleep(5000)

        Catch ex As Exception
            MsgBox(Err.Description)
        End Try
    End Sub
End Class


Also the standalone Cefsharp works fine, i am able to browse website etc, but when i pair it with selenium it crashes and chromedriver prints this error.

---------------------------
chromedriver
---------------------------
unknown error: Chrome failed to start: crashed.
  (chrome not reachable)
  (The process started from chrome location CefSharp.MinimalExample.WinForms.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
---------------------------
OK  
---------------------------

I have tried below options:

tried with latest chrome driver and cef versions
Ran code as admin
Used x86 version of cefsharp exe
Below are the logs written while executing above code

chromedriver console log:

Starting ChromeDriver 107.0.5304.62 (1eec40d3a5764881c92085aaee66d25075c159aa-refs/branch-heads/5304@{#942}) on port 61991          
Only local connections are allowed.        
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.          
ChromeDriver was started successfully.          
[0214/160638.323:VERBOSE1:pref_proxy_config_tracker_impl.cc(187)] 342B4700: set chrome proxy config service to 34238700        
[0214/160638.403:VERBOSE1:webrtc_internals.cc(120)] Could not get the download directory.          
[0214/160638.407:VERBOSE1:media_stream_manager.cc(1100)] MSM::InitializeMaybeAsync([this=34260840])        
[0214/160638.409:VERBOSE1:media_stream_manager.cc(1100)] MDM::MediaDevicesManager()        
[0214/160638.409:VERBOSE1:media_stream_manager.cc(1100)] MSM::MediaStreamManager([this=34260840]))          
           
DevTools listening on ws://127.0.0.1:20480/devtools/browser/d1d13b12-10ad-4cb6-ad07-b948e92d26d6            
[0214/160638.481:VERBOSE1:component_installer.cc(285)] StartRegistration for Widevine Content Decryption Module        
[0214/160638.482:VERBOSE1:first_party_sets_handler_impl.cc(279)] Empty path. Failed initializing First-Party Sets database.        
[0214/160638.502:VERBOSE1:component_installer.cc(439)] FinishRegistration for Widevine Content Decryption Module            
[0214/160638.509:VERBOSE1:component_updater_service.cc(131)] CrxUpdateService starting up. First update attempt will take place in 60 seconds. Next update attempt will take place in 18000 seconds.            
[0214/160638.599:VERBOSE1:pref_proxy_config_tracker_impl.cc(187)] 342B6D80: set chrome proxy config service to 3423A800        
[0214/160653.789:INFO:child_thread_impl.cc(918)] ChildThreadImpl::EnsureConnected()

Debug log:
[0214/160638.323:VERBOSE1:pref_proxy_config_tracker_impl.cc(187)] 342B4700: set chrome proxy config service to 34238700    
[0214/160638.403:VERBOSE1:webrtc_internals.cc(120)] Could not get the download directory.      
[0214/160638.407:VERBOSE1:media_stream_manager.cc(1100)] MSM::InitializeMaybeAsync([this=34260840])    
[0214/160638.409:VERBOSE1:media_stream_manager.cc(1100)] MDM::MediaDevicesManager()    
[0214/160638.409:VERBOSE1:media_stream_manager.cc(1100)] MSM::MediaStreamManager([this=34260840]))      
[0214/160638.481:VERBOSE1:component_installer.cc(285)] StartRegistration for Widevine Content Decryption Module    
[0214/160638.482:VERBOSE1:first_party_sets_handler_impl.cc(279)] Empty path. Failed initializing First-Party Sets database.    
[0214/160638.502:VERBOSE1:component_installer.cc(439)] FinishRegistration for Widevine Content Decryption Module        
[0214/160638.509:VERBOSE1:component_updater_service.cc(131)] CrxUpdateService starting up. First update attempt will take place in 60 seconds. Next update attempt will take place in 18000 seconds.        
[0214/160638.599:VERBOSE1:pref_proxy_config_tracker_impl.cc(187)] 342B6D80: set chrome proxy config service to 3423A800    
[0214/160653.789:INFO:child_thread_impl.cc(918)] ChildThreadImpl::EnsureConnected()
 
How can i bind cefsharp with selenium? 
Reply all
Reply to author
Forward
0 new messages