-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I using following code:
using System;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using BaristaLabs.ChromeDevTools.Runtime;
using Page = BaristaLabs.ChromeDevTools.Runtime.Page;
namespace BaristaChromeDevToolsTest
{
class Program
{
//Launch Chrome With
//"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9223
static async Task Main(string[] args)
{
var sessions = await GetSessions("http://localhost:9223/");
using (var session = new ChromeSession(sessions.First(s => s.Type == "page").WebSocketDebuggerUrl))
{
await session.Page.Enable();
await session.DOM.Enable();
var loaded = new SemaphoreSlim(0, 1);
var inserted = new SemaphoreSlim(0, 1);
session.Page.SubscribeToLoadEventFiredEvent((e) =>
{
loaded.Release();
});
var navigateResult = await session.Page.Navigate(new Page.NavigateCommand
{
Url = "http://www.amazon.com"
});
// await loaded.WaitAsync();
session.DOM.SubscribeToChildNodeInsertedEvent((e) => {
inserted.Release();
});
await inserted.WaitAsync();
Console.WriteLine("inserted");
}
Console.ReadKey();
}
public static async Task<ICollection<ChromeSessionInfo>> GetSessions(string chromeUrl)
{
using (var webClient = new HttpClient())
{
webClient.BaseAddress = new Uri(chromeUrl);
var remoteSessions = await webClient.GetStringAsync("/json");
return JsonConvert.DeserializeObject<ICollection<ChromeSessionInfo>>(remoteSessions);
}
}
}
}
Next I opening devtools in this Chrome, evaluating code like such:
var el = document.createElement('div');
document.body.appendChild(el);
...and still no "inserted" in console.
But if I open devtools protocol monitor, I will see DOM.childNodeInserted was called.
Also:
https://chromedevtools.github.io/devtools-protocol/tot/DOM#event-childNodeInserted
DOM.childNodeInserted
Mirrors DOMNodeInserted event.
If I directly subscribe DOMNodeInserted - it fires.
Propose you to write more unit tests.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels