Example #1
0
        private static void Test(string firstUrl)
        {
            using (MyClientWebSocket ws = new MyClientWebSocket(firstUrl))
            {
                ws.Open("http://www.duckduckgo.com", CancellationToken.None);
                ws.WaitForDocumentReady();
                ws.FillAsync("#search_form_input_homepage", "Test", CancellationToken.None).Wait();
                ws.ClickAsync("#search_button_homepage", CancellationToken.None).Wait();
                ws.WaitForDocumentReady();
            }

            using (MyClientWebSocket ws = new MyClientWebSocket(firstUrl))
            {
                var title = ws.EvaluateWithReturn("document.title", CancellationToken.None);
                Console.WriteLine(title);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            Console.Title = "Worker Remote Debugging";

            var dir = AppDomain.CurrentDomain.BaseDirectory;

            dir = Path.GetFullPath(Path.Combine(dir, @"..\..\..\"));

            Process.Start(Path.Combine(dir, @"GoogleChromePortable\GoogleChromePortable.exe"), "--remote-debugging-port=9222 about:blank");

            while (!UrlExists("http://*****:*****@Node}", node),
                                                                               url =>
            {
                using (MyClientWebSocket ws = new MyClientWebSocket(firstUrl))
                {
                    ws.Open(url, CancellationToken.None);
                    ws.WaitForDocumentReady();

                    return(Task.FromResult(true));
                }
            },
                                                                               script =>
            {
                using (MyClientWebSocket ws = new MyClientWebSocket(firstUrl))
                {
                    string value = ws.EvaluateWithReturn(script, CancellationToken.None);
                    ws.WaitForDocumentReady();

                    return(Task.FromResult(value));
                }
            },
                                                                               async node => await Bus.PublishAsync(node),
                                                                               async node => await Bus.PublishAsync(new Result {
                Node = node
            }),
                                                                               async node =>
            {
                Logger.Error("{@Node}", node);
                await Bus.PublishAsync(new ErrorResult {
                    Node = node
                });
            },
                                                                               node => { }));

            //Test(firstUrl);

            Console.ReadLine();

            SubscriptionResult.Dispose();

            var chromePoratable = Process.GetProcessesByName("GoogleChromePortable");

            chromePoratable.ToList().ForEach(x => IgnoreExceptions(() => x.Kill()));

            Environment.Exit(0);
        }