Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Oleg Zudov
    @ToCSharp
    In Chrome all interacts through DevTools connection. Selenium connects to chromedriver.exe, which connects to Chrome DevTools
    JasonTurnbull25
    @JasonTurnbull25
    And selenium/webdriver/chromedriver have no way to access devtools sessions the way yours does, as far as I can tell.
    Oleg Zudov
    @ToCSharp
    Maybe it possible through scripts, I cannot say now
    IJavaScriptExecutor
    JasonTurnbull25
    @JasonTurnbull25
    I'm an amateur. I have no idea how I'd go about using IJavaScriptExecutor in selenium to access devtools. But I'm sure it's possible. Is there any way to pass command line arguments to the headless chromebrowser? A ChromeOptions or some other method?
    Oleg Zudov
    @ToCSharp
    Sorry, it's late in my country. Tomorrow
    JasonTurnbull25
    @JasonTurnbull25
    Sorry, Goodnight Oleg. Thanks for the help.
    JasonTurnbull25
    @JasonTurnbull25
    I know you're busy, but if you get a chance, I have two features I would like to be able to use. I'd like to be able to choose the executable that your software uses. Basically pick my own chrome.exe and path. The other is the ability to pass standard command line arguments to the chrome executable. If you happen to get these options in at some point, please let me know :)
    Oleg Zudov
    @ToCSharp
    Path to chrome.exe in static property ChromeProfilesWorker.ChromeBinaryFileName https://github.com/ToCSharp/AsyncChromeDriver/blob/862d692960532895670074d8b915529474b4f37b/AsyncChromeDriver/ChromeProfilesWorker.cs#L21 . You may change it
    Oleg Zudov
    @ToCSharp
    Please try new ChromeDriverConfig().SetCommandLineArgumets("...")
    It adds args to other port, userdir, headless and so on
    JasonTurnbull25
    @JasonTurnbull25
    Thanks Oleg, I'll try soon and let you know how they work :)
    JasonTurnbull25
    @JasonTurnbull25
    Everything works. One little thing though. When I use --user-data-dir to specify a profile it get's overridden by one that seems to be hardcoded. Looks like it may be getting set wherever you're setting --remote-debugging-port=11752 and it looks like this:--user-data-dir="C:\Users\Work\AppData\Local\Temp\henqnzur.1jw" --bwsi
    JasonTurnbull25
    @JasonTurnbull25
    Sorry, I think I may have found that under profileworker, lol. My mistake.
    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));