Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SubscribeToLoadEventFiredEvent does nothing #4

Open
ygoe opened this issue Oct 9, 2018 · 1 comment
Open

SubscribeToLoadEventFiredEvent does nothing #4

ygoe opened this issue Oct 9, 2018 · 1 comment

Comments

@ygoe
Copy link

ygoe commented Oct 9, 2018

The SubscribeToLoadEventFiredEvent method is supposed to register a callback function for when the page has loaded. The page does load, but the event callback function is never called. I cannot find any information about what lies beneath this method so I'm stuck. Is there any understandable documentation about that remote access protocol available?

@Oceanswave
Copy link
Member

Oceanswave commented Nov 9, 2018

Hi!

An example of subscribing to events is located in the unit tests, for instance:

using (var session = new ChromeSession(m_currentChromeSessionInfo.WebSocketDebuggerUrl))
            {
                await session.Page.Enable();

                session.Page.SubscribeToLoadEventFiredEvent(async (e) =>
                {
                    var screenshot = await session.Page.CaptureScreenshot(new Page.CaptureScreenshotCommand());
                    if (!string.IsNullOrWhiteSpace(screenshot.Data))
                    {
                        File.WriteAllBytes(fileName, Convert.FromBase64String(screenshot.Data));
                        m_testContext.WriteLine($"saved to {fileName}");
                        s.Release();
                    }
                });

                var navigateResult = await session.Page.Navigate(new Page.NavigateCommand
                {
                    Url = "https://www.google.com"
                });

                await s.WaitAsync();
                Assert.IsTrue(File.Exists(fileName));
            }

The associated events must be enabled via Page.Enable(). HTH!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants