Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Oleg Zudov
    @ToCSharp
    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.
    problems with framework 4.6.1 :S
    Oleg Zudov
    @ToCSharp
    Hi, can you use framework 4.6.2 ?
    p3t3rBl4ck
    @p3t3rBl4ck
    ok, I will try with 4.6.2. Thanks!
    p3t3rBl4ck
    @p3t3rBl4ck
    work it !! Thanks :)
    p3t3rBl4ck
    @p3t3rBl4ck
            var options = new ChromeOptions();
            options.AddArguments("--disable-gpu");
    
            options.AddArguments("headless");
    
            options.AddUserProfilePreference("profile.default_content_setting_values.images", 2);
    How can I get a ChromeOptions in ASyncWebDriver ? Thanks
    Oleg Zudov
    @ToCSharp
    Now we can: var lowerAttribute = await driver.FindElement(By.Id("element")).GetAttribute("value").ToLower()
    @p3t3rBl4ck Sorry, I missed your question. I'll see what to do.
    Oleg Zudov
    @ToCSharp
    var asyncChromeDriver = new AsyncChromeDriver(new ChromeDriverConfig().SetHeadless().SetCommandLineArgumets("--disable-gpu").SetWindowSize(width, height).SetIsTempProfile());
    var webDriver = new WebDriver(asyncChromeDriver);
    await webDriver.GoToUrl("https://www.google.com/");
    Are you sure it is Chrome option? Or it is from Firefox?
    options.AddUserProfilePreference("profile.default_content_setting_values.images", 2);
    Xavid Ramirez
    @xavidram
    Good Afternoon Oleg. Will you be implementing the Target Switching in the near future?
    Oleg Zudov
    @ToCSharp
    Hi. Tests on frames switching are here:
    https://github.com/ToCSharp/AsyncChromeDriver/blob/master/AsyncChromeDriver.Tests/TargetLocatorTest.cs
    I corrected a bit. It seems switching works, except exceptions when not correct index, name or id.
    Before run test, start HtmlForTests (Start Without Debugging in VS).
    Would be great, if you write your test that fails
    Oleg Zudov
    @ToCSharp
    @xavidram Sorry that I did not reply for a while
    Xavid Ramirez
    @xavidram
    Thanks. I'll take a look in a bit and add some tests that I see fail. I'll send a PR when I can.
    radia
    @radiaku
    Hello, is AsyncWebDriver can control multiple chrome, with One port debug?
    FosseGrim
    @egorsh0
    Hey. Tell me, please, is there any way to do basic authentication?
    Xavid Ramirez
    @xavidram
    @egorsh0 in most websites, you can still use URL authentication, rather than have to do basic authentication. I've had to use it as a workaround.
    oneprofittips
    @oneprofittips
    Добрый день. Можете подсказать как нужно реализовывать иннтерфейс IWindow
    для реализации изменения размера окна https://github.com/ToCSharp/AsyncChromeDriver/blob/master/AsyncChromeDriver/IAsyncWebBrowserClient/ChromeDriverWindow.cs
    oneprofittips
    @oneprofittips
    Good afternoon. Where can I view the commands for minimizing the browser window?