public void findKey(string key) { Thread.Sleep(5000); var control = FirefoxWebUITest.WaitUntilPageExistsControl(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + key + "'])[2]/following::div[1]")); if (control != null) { control.Click(); } else { InvokeControlAction(textBox1, new Action <TextBox>((b) => { b.Text = "没找到" + key + "关键字,继续查找" + "\r\n"; })); findKey(key); } }
private void money() { try { isF = !isF; var productKey = textBox2.Text; FirefoxWebUITest.OpenBrowser(textBox3.Text); findKey(productKey); while (true) { catchControlValue(getNames()); //catchControlValue(new string[] { "A.科奈特", "伊萬•宋" }); InvokeControlAction(textBox1, new Action <TextBox>((b) => { b.Text += b.Text + "\r\n" + "------------------------华丽分割线,必出BUG-----------------------------" + "\r\n"; })); Thread.Sleep(1000); } } catch (Exception ex) { if (isF) { textBox3.Text = "https://mobile.48-365365.com/default.aspx?apptype=&appversion=&rnd=66392#type=InPlay;key=;ip=1;lng=2"; } else { textBox3.Text = "https://mobile.356884.com/#type=InPlay;key=;ip=1;lng=28"; } InvokeControlAction(textBox1, new Action <TextBox>((b) => { b.Text = "StackTrace:" + ex.StackTrace + "Message:" + ex.Message + "\r\n"; })); FirefoxWebUITest.CloseAll(); Thread.Sleep(3000); money(); } }
private void NewMethod(string item, IWebElement value) { try { value.Click(); //if (FirefoxWebUITest.IsElementPresent(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='點擊以切換至其它比賽'])[1]/following::div[1]"))) //{ // FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='點擊以切換至其它比賽'])[1]/following::div[1]")).Click(); //} string html = FirefoxWebUITest.Driver.PageSource; int iBodyStart = html.IndexOf("局獲勝者", 0); //开始位置 if (iBodyStart != -1) { int iBodyEnd = html.IndexOf("</span>", iBodyStart); //第二次字符在第一次字符位置起的首次位置 if (iBodyEnd != -1) { int indeA = iBodyStart - 2; int indeB = iBodyEnd - iBodyStart + 2; string currentSituation = html.Substring(indeA, indeB);//当前对局 if (!currentSituation.Contains("第")) { currentSituation = "第" + currentSituation; } string serveName = item.Trim() + " (發球局)";//發球局人的名字 string matchName = Crawler(html, "<span class=\"ipe-EventViewTitle_Text\">", "</span>"); if (!string.IsNullOrEmpty(matchName)) { string div = Crawler(html, currentSituation, "<div class=\"ipe-Market_FavStar \"></div>"); string a = matchName.Substring(0, matchName.IndexOf(" v ")).Trim(); string b = matchName.Substring(matchName.IndexOf(" v ") + 3).Trim(); if (div.Contains(serveName))//发球者是item { FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + currentSituation + "'])[1]/following::div[3]")).Click(); } else { if (item != a) { serveName = a + " (發球局)"; FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + serveName + "'])[1]/following::div[1]")).Click(); } if (item != b) { serveName = b + " (發球局)"; FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + serveName + "'])[1]/following::div[1]")).Click(); } } matchName = a + " v " + b; FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + matchName + "'])[1]/following::input[1]")).Click(); FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + matchName + "'])[1]/following::input[1]")).Clear(); FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='" + matchName + "'])[1]/following::input[1]")).SendKeys("2"); if (FirefoxWebUITest.IsElementPresent(By.ClassName("acceptChanges abetslipBtn"))) { FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='走地盤投注會稍有延遲'])[1]/following::button[1]")).Click(); //赔率变更 } FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='接受变化'])[1]/following::button[1]")).Click(); //投钱 if (FirefoxWebUITest.IsElementPresent(By.LinkText("保留這些選項"))) { FirefoxWebUITest.Driver.FindElement(By.LinkText("保留這些選項")).Click(); } Thread.Sleep(60000); FirefoxWebUITest.Driver.FindElement(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='投注單'])[1]/following::a[1]")).Click();//后退按钮 } } } } catch (Exception ex) { FirefoxWebUITest.Refresh(); FirefoxWebUITest.WaitUntilPageExistsControl(By.XPath("(.//*[normalize-space(text()) and normalize-space(.)='投注單'])[1]/following::a[1]")).Click();//后退按钮 } }