Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    JasonTurnbull25
    @JasonTurnbull25
    Actually, I'm still having trouble setting it. If you have an example of using the profileWorker to change binary path and user-data directory that would be great.
    new ChromeDriverConfig { UserDir ="..", Headless = true, IsTempProfile = false, WindowSize = new WebSize(800, 600) }
    set IsTempProfile = false, if true it delete dir when closing Chrome
    Set ChromeProfilesWorker.ChromeBinaryFileName before opening Chrome. Must work
    I'll check ChromeProfilesWorker.ChromeBinaryFileName later
    JasonTurnbull25
    @JasonTurnbull25
    Thank you again Oleg. I appreciate the help.
    Oleg Zudov
    @ToCSharp
    Big architecture change committed today.
    IAsyncWebBrowserClient moved to its own repository https://github.com/ToCSharp/IAsyncWebBrowserClient.
    It is center point of my webbrowser projects.
    Please, take a look. I value your opinion.
    Update the nuget packages.
    Write here any problems
    Oleg Zudov
    @ToCSharp
    Hello. I have made SeleniumAdapter.
    Now we can run Unit Tests from Selenuim through SeleniumAdapter -> SyncWebDriver -> AsyncWebDriver -> AsyncChromeDriver
    Oleg Zudov
    @ToCSharp
    You may see what is not implemented. For me it's enough now. I will implement features if you ask. Write here
    Oleg Zudov
    @ToCSharp
    Firefox 56 supports headless mode:
     asyncFirefoxDriver = new AsyncFirefoxDriver(new FirefoxDriverConfig().SetHeadless().SetWindowSize(1200, 900));
     webDriver = new WebDriver(asyncFirefoxDriver);
     await webDriver.GoToUrl("https://www.bing.com/");
     var screenshot = await webDriver.GetScreenshot();
     using (MemoryStream imageStream = new MemoryStream(screenshot.AsByteArray))
     {
         System.Drawing.Image screenshotImage = System.Drawing.Image.FromStream(imageStream);
         screenshotImage.Save(@"C:\temp\screenshot.png", System.Drawing.Imaging.ImageFormat.Png);
     }
    Oleg Zudov
    @ToCSharp
    Working on asyncFirefoxDriver.OpenBrowserDevTools();
    We can open Firefox developer tools with some limitations:
      var profileName = tbOpenProfileName.Text;
      asyncFirefoxDriver = new AsyncFirefoxDriver(
          new FirefoxDriverConfig()
          .SetProfileName(profileName)
          .SetIsMultiprocessFalse()
          .SetDoSetDebuggerRemoteEnabled());
      webDriver = new WebDriver(asyncFirefoxDriver);
      await webDriver.GoToUrl("https://www.google.com/");
      await asyncFirefoxDriver.OpenBrowserDevTools();
      // asyncFirefoxDriver.BrowserDevTools is AsyncFirefoxDriver
      devToolsWebDriver = new WebDriver(asyncFirefoxDriver.BrowserDevTools);
      //// TODO: not works SwitchTo().Frame("toolbox-iframe");  listener.js 1715
      //await devToolsWebDriver.SwitchTo().Frame("toolbox-iframe");
      //var inspectorTab = await devToolsWebDriver.FindElementById("toolbox-tab-inspector");
      //await inspectorTab.Click();
    DevTools not work in Multiprocess with content
    Then we can debug Firefox developer tools itself:
    await asyncFirefoxDriver.BrowserDevTools.OpenBrowserDevTools(9654);
    Oleg Zudov
    @ToCSharp
    FindElement methods improved:
        await webDriver.Options().Timeouts.SetImplicitWait(TimeSpan.FromSeconds(3));
        // name = "q", 0 - time to wait element, not use ImplicitWait
        var prevQuery = await webDriver.FindElementByNameOrDefault("q", 0);
        var res2 = await webDriver.GoToUrl("https://www.google.com/");
        // if element with name "q" from prev page wait for new element with name "q"
        var query = await webDriver.FindElementByName("q", prevQuery?.Id);
    FindElementByNameOrDefault will not throw Exception if no element, return null
    Oleg Zudov
    @ToCSharp
    We can open second window with Chrome Developer Tools now:
       asyncChromeDriver = new AsyncChromeDriver(
            new ChromeDriverConfig().SetDoOpenBrowserDevTools());
       webDriver = new WebDriver(asyncChromeDriver);
       await asyncChromeDriver.Connect();
    And use WebDriver, asyncChromeDriver.DevTools and Chrome native Developer Tools in parallel
    AsyncChromeDriver opens WebSocket proxy for them
    Oleg Zudov
    @ToCSharp
    BrowsersDevToolsExample
    Example of using Browser's Developer tools while using AsyncChromeDriver, AsyncOperaDriver and AsyncFirefoxDriver.
    Oleg Zudov
    @ToCSharp
    Open Chrome native Developer tools for opened Chrome native Developer tools:
       asyncChromeDriver = new AsyncChromeDriver(new ChromeDriverConfig().SetDoOpenBrowserDevTools());
       asyncChromeDriver.BrowserDevToolsConfig = new ChromeDriverConfig().SetDoOpenBrowserDevTools();
       webDriver = new WebDriver(asyncChromeDriver);
       await asyncChromeDriver.Connect();
    Oleg Zudov
    @ToCSharp
    asyncChromeDriver.BrowserDevTools is AsyncChromeDriver, so we can interact with BrowserDevTools as AsyncWebDriver with some difficulties, because tabs behind shadowRoots. Look example :
      var wd = new WebDriver(asyncChromeDriver.BrowserDevTools);
      var el = await wd.ExecuteScript(shadowFind + "return recursiveFindById(document, 'tab-sources', [])[0];") as AsyncWebElement;
      await el.Click();
    Firefox BrowserDevTools also accessible, but here difficulties because they are in XUL:
      await asyncFirefoxDriver.BrowserDevTools.JavaScriptExecutor
        .ExecuteScript("frames[0].document.getElementById('toolbox-tab-netmonitor').click();");
    Oleg Zudov
    @ToCSharp
    When we open Chrome or Opera BrowserDevTools, WebSocket server starts to proxy WS traffic. So your firewall will ask you for permission. By default WebSocket server and http proxy server for DevTools frontend accepts only local connections. So it is safe.
    Oleg Zudov
    @ToCSharp
    Look video of BrowsersDevToolsExample: https://youtu.be/dNMuoeDmEME
    Paraig
    @Paraig
    Hi Oleg, I am using your AsyncChromeDriver to manage communications between a Windows desktop application and Chrome. As part of our workflow we send navigation requests to a web application via Chrome, we then use a custom Protocol ("afe") to send confirmations back to our desktop application. Chrome prompts us to enable the protocol and if the user checks the box Chrome updates the user's preference file, adding "afe":false the the protocol_handler section, so the following will appear "protocol_handler":{"excluded_schemes":{"afe": false}}. The browser session/process created by AsyncChromeDriver will create an empty "protocol_handler": "excluded_schemes" entry but doesn't add the "afe":false. Have you ever encountered this or is this a limitation of the Chrome DevTools? I would be very interested in any ideas/work-arounds you may know.
    Oleg Zudov
    @ToCSharp

    @Paraig Hi.

    var asyncChromeDriver = new AsyncChromeDriver();

    creates temp profile every time. Try

    asyncChromeDriver = new AsyncChromeDriver(new ChromeDriverConfig().SetUserDir(userDir));
    Paraig
    @Paraig
    Hi Oleg, Thank you for your reply, when I try this the
    var profile = new ChromeDriverConfig()
    {
    UserDir = ProfilePath,// GetUserProfileDirectory().Result,
    CommandLineArgumets = BuildStandardCommandLine()
    };
    _asyncChromeDriver = new AsyncChromeDriver(profile);
                _webDriver = new WebDriver(_asyncChromeDriver);
    
                await _asyncChromeDriver.Connect();
    Above is a code snippet that I use to initiate the connection to Chrome, I do not see the profile created until after the Connect method is called. There then seems to be a delay before I can access the profile.
    Paraig
    @Paraig
    What we are trying to do is create a profile by creating a Chrome instance using the above code. We then kill the Chrome process and update the preferences file using Json and then create a new instance of Chrome, that new instance should pick up the updated preferences. I have noticed that the preference file isn't always present.
    Oleg Zudov
    @ToCSharp
    https://github.com/ToCSharp/IAsyncWebBrowserClient/blob/master/IAsyncWebBrowserClient/BasicTypes/DriverConfig.cs
    ChromeDriverConfig : DriverConfig
    When you do: var profile = new ChromeDriverConfig()
    {
    UserDir = ProfilePath,// GetUserProfileDirectory().Result,
    CommandLineArgumets = BuildStandardCommandLine()
    };
    IsTempProfile stays true, and it will delete this profile on close
    new ChromeDriverConfig().SetUserDir(userDir) sets IsTempProfile = false;
    add profile.IsTempProfile = false
    Oleg Zudov
    @ToCSharp
    Sorry, I have no time to write wiki now. May be when it be more popular. Now ask questions here
    Oleg Zudov
    @ToCSharp

    And, yes. Browser starts(or creates profile if dir empty) here:

    await _asyncChromeDriver.Connect();

    or here

    await webDriver.GoToUrl("https://www.google.com/");

    or here

    await _webDriver.Open();
    It gives us do some things before opening. For example look temp dir, driver wants to create
    JasonTurnbull25
    @JasonTurnbull25
    Hi Oleg. is there any way to start chrome externally and pass the process over to your asyncChromeDriver rather than having AsyncChromeDriver launch the process?
    Oleg Zudov
    @ToCSharp
                var chromeBinaryFileName = @"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe";
                var args = @"--remote-debugging-port=12255 --user-data-dir=""C:\Chrome\profiles\test1""";
                process = new Process();
                process.StartInfo.FileName = chromeBinaryFileName;
                process.StartInfo.Arguments = args;
                process.StartInfo.UseShellExecute = false;
                process.Start();
    
                var asyncChromeDriver = new AsyncChromeDriver(
                            new ChromeDriverConfig { 
                                   DoNotOpenChromeProfile = true, 
                                   IsTempProfile = false, 
                                   Port = 12255 
                });
                var webDriver = new WebDriver(asyncChromeDriver);
                await webDriver.GoToUrl("https://www.google.com/");
    
                await Task.Delay(5000);
                process.CloseMainWindow();
    JasonTurnbull25
    @JasonTurnbull25
    Thanks Oleg :)
    p3t3rBl4ck
    @p3t3rBl4ck
    hi
    I would like use the ASyncWebDriver in my proyect but I have a problem when I try install it from nuget.