You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have following code based on official sample of this project:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using Task = System.Threading.Tasks.Task;
using System.Windows.Forms;
using MasterDevs.ChromeDevTools;
using DOM = MasterDevs.ChromeDevTools.Protocol.Chrome.DOM;
using Emulation = MasterDevs.ChromeDevTools.Protocol.Chrome.Emulation;
using Page = MasterDevs.ChromeDevTools.Protocol.Chrome.Page;
namespace FreelanceRuBot
{
class Program
{
const int ViewPortWidth = 1440;
const int ViewPortHeight = 900;
static void Main(string[] args)
{
Task.Run(async () =>
{
var getHTMLDone = new ManualResetEventSlim();
var chromeProcessFactory = new ChromeProcessFactory(new StubbornDirectoryCleaner());
using (var chromeProcess = chromeProcessFactory.Create(9222, true))
{
var sessionInfo = (await chromeProcess.GetSessionInfo()).LastOrDefault();
var chromeSessionFactory = new ChromeSessionFactory();
var chromeSession = chromeSessionFactory.Create(sessionInfo.WebSocketDebuggerUrl);
await chromeSession.SendAsync(new Emulation.SetVisibleSizeCommand
{
Width = ViewPortWidth,
Height = ViewPortHeight
});
var navigateResponse = await chromeSession.SendAsync(new Page.NavigateCommand
{
Url = "http://www.google.com"
});
var pageEnableResult = await chromeSession.SendAsync<Page.EnableCommand>();
chromeSession.Subscribe<Page.LoadEventFiredEvent>(loadEventFired =>
{
Task.Run(async () =>
{
var doc = (await chromeSession.SendAsync(new DOM.GetDocumentCommand())).Result.Root;
var res = chromeSession.SendAsync(new DOM.GetOuterHTMLCommand());
getHTMLDone.Set();
});
});
getHTMLDone.Wait();
Console.WriteLine("Exiting ..");
}
}).Wait();
}
}
}
Some error occurs in this line;
var res = chromeSession.SendAsync(new DOM.GetOuterHTMLCommand());
But it is not issue about an error. It is issue about how to handle such errors.
This line hasn't any result processing, but anyway it crashes with: System.InvalidCastException. Place is ChromeSession.cs, CastTaskResult method, 94 line.
Because it can't cast "MasterDevs.ChromeDevTools.ErrorResponse" to "MasterDevs.ChromeDevTools.CommandResponse`.
I want to obtain ErrorResponse in such case. But it looks like there are no normal way to obtain it.
P. S. I could contribute if you will merge :)
The text was updated successfully, but these errors were encountered:
I have following code based on official sample of this project:
Some error occurs in this line;
But it is not issue about an error. It is issue about how to handle such errors.
This line hasn't any result processing, but anyway it crashes with: System.InvalidCastException. Place is ChromeSession.cs, CastTaskResult method, 94 line.
Because it can't cast "MasterDevs.ChromeDevTools.ErrorResponse" to "MasterDevs.ChromeDevTools.CommandResponse`.
I want to obtain ErrorResponse in such case. But it looks like there are no normal way to obtain it.
P. S. I could contribute if you will merge :)
The text was updated successfully, but these errors were encountered: