static void Main(string[] args) { var chrome = new Chrome("http://localhost:9222"); var sessions = chrome.GetAvailableSessions(); Console.WriteLine("Available debugging sessions"); foreach (var s in sessions) { Console.WriteLine(s.url); } if (sessions.Count == 0) { throw new Exception("All debugging sessions are taken."); } // Will drive first tab session var sessionWSEndpoint = sessions[0].webSocketDebuggerUrl; chrome.SetActiveSession(sessionWSEndpoint); chrome.NavigateTo("http://www.google.com"); var result = chrome.Eval("document.getElementById('lst-ib').value='Hello World'"); result = chrome.Eval("document.forms[0].submit()"); Console.ReadLine(); }
private void StartConnectSessionAndGotoUpbit(RemoteSession session) { Thread connectSession = new Thread(new ThreadStart(() => { Chrome chrome = new Chrome(); chrome.Connect(session.webSocketDebuggerUrl); chrome.Eval(Commands.NavigateTo("http://upbit.com/exchange")); lock (locker) { int browserid = CountAdded + 1; chrome.SetBrowserId(browserid); string name = this.CoinsIndexed[this.CountAdded]; this.Browsers.Add(name, chrome); this.CountAdded++; this.OnSocketConnected(this, new SocketConnectedEventArgs(this.CountAdded, this.Coins.Count * 2)); if (this.CountAdded == this.Coins.Count * 2) { this.OnComplete(this, new AttachBrowsersCompleteEventArgs(this.Browsers)); } } })); connectSession.Start(); }
private void DiscountBuy(string pair, decimal amount) { Chrome chrome = Browsers[pair]; // Order tab chrome.Eval(Commands.ClickBuyTab()); // Check for enough fund decimal fiat = Properties.Settings.Default.CycleMoney * (decimal)2 * 1000; bool available = chrome.EvalAndGet(Commands.CheckAmountAvailable(amount)); if (!available) { throw new Exception(String.Format("Not enough funds (KRW): Need {0}", fiat)); } // Order chrome.Eval(Commands.Buy(9, amount)); }
private void PremiumBuy(string pair, decimal amount) { Chrome chrome = Browsers[pair]; // Order tab chrome.Eval(Commands.ClickBuyTab()); // tested // Check for enough fund decimal fiat = Properties.Settings.Default.CycleMoney * (decimal)1.5; bool available = chrome.EvalAndGet(Commands.CheckAmountAvailable(fiat)); // 0.01 if (!available) { throw new Exception(String.Format("Not enough funds (USDT): Need {0}", fiat)); } // Order chrome.Eval(Commands.Buy(9, amount)); Debug.End("fill in and click buy: "); // chrome.EvalUntil(Commands.WaitConfirmBuy()); string orderResult; orderResult = chrome.EvalAndGet(Commands.ConfirmBuy()); orderResult = orderResult.Replace("__buffer__", ""); Console.WriteLine(orderResult); OrderResult result = JsonConvert.DeserializeObject <OrderResult>(orderResult); result.Type = OrderResult.BUY; result.Pair = pair; result.Fee = result.TotalCost * (decimal)0.0025; Debug.End("order result: "); chrome.EvalUntil(Commands.ConfirmOrderWait()); chrome.Eval(Commands.ConfirmOrder()); Debug.End("confirm: "); }
static void Main(string[] args) { //chrome.exe --remote-debugging-port=9222 --user-data-dir=C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data //chrome.exe --remote-debugging-port=9222 --user-data-dir=C:\myChromeUser var chrome = new Chrome("http://localhost:9222"); var sessions = chrome.GetAvailableSessions(); Console.WriteLine("Available debugging sessions"); foreach (var s in sessions) { Console.WriteLine(s.url); } if (sessions.Count == 0) { throw new Exception("All debugging sessions are taken."); } var sessionWSEndpoint = sessions[0].webSocketDebuggerUrl; chrome.SetActiveSession(sessionWSEndpoint); //var result = chrome.Eval("alert(window.getSelection().toString())"); var result = chrome.Eval("window.getSelection().toString()"); //var result = chrome.Eval("window.getSelection()"); Console.WriteLine(result); //////// Will drive first tab session //////var sessionWSEndpoint = sessions[0].webSocketDebuggerUrl; //////chrome.SetActiveSession(sessionWSEndpoint); //////chrome.NavigateTo("http://www.google.com"); //////var result = chrome.Eval("document.getElementById('lst-ib').value='Hello World'"); //////result = chrome.Eval("document.forms[0].submit()"); Console.ReadLine(); }
private void StartConnectSessionAndGotoPage(Chrome chrome, string webSocketDebuggerUrl, string pairUri) { new Thread(new ThreadStart(() => { chrome.Connect(webSocketDebuggerUrl); chrome.Eval(Commands.NavigateTo("https://upbit.com/exchange?code=CRIX.UPBIT." + pairUri)); lock (locker) { int browserid = CountAdded + 1; chrome.SetBrowserId(browserid); this.CountAdded++; this.OnSocketConnected(this, new SocketConnectedEventArgs(this.CountAdded, this.CountTotal)); if (this.CountAdded == this.CountTotal) { this.OnComplete(this, new AttachBrowsersCompleteEventArgs(this.Browsers)); } } })).Start(); }