Example #1
0
        private void RunLoopMainStep2()
        {
            UtilsLog.Log("RunLoopMainStep2 ENTER");

            HtmlElement eledxpdateselectionview = webBrowser1.Document.GetElementById("dxp-date-selection-view");

            if (eledxpdateselectionview != null)
            {
                List <HtmlElement> eledxpdateselectionviewItems = new List <HtmlElement>();
                UtilsHtml.FindElementHtmlElements(eledxpdateselectionview, ":div/:div/:div/:div/class:page-messages/:div/class:title-container/:div/class:title/:span", eledxpdateselectionviewItems);
                if (eledxpdateselectionviewItems.Count > 0)
                {
                    HtmlElement elemappItem = eledxpdateselectionviewItems[0];
                    if (elemappItem.InnerText.Contains("未找到航班"))
                    {
                        //失败
                        RunLoopSleep(5000);
                        step++;
                    }
                }
            }

            HtmlElement eledxpflighttablesection = webBrowser1.Document.GetElementById("dxp-flight-table-section");

            if (eledxpflighttablesection != null)
            {
                //成功
                RunLoopSleep(2000);
                step += 3;
            }
        }
Example #2
0
        private void RunLoopMainStep11()
        {
            HtmlElement elemreactselect5value = webBrowser1.Document.GetElementById("react-select-5--value");

            UtilsLog.Log("RunLoopMainStep11 elemreactselect5value={0}", elemreactselect5value);
            if (elemreactselect5value == null)
            {
                return;
            }

            int scrollLeft = GetDocumentScrollLeft();
            int scrollTop  = GetDocumentScrollTop();

            UtilsLog.Log("RunLoopMainStep11 scrollLeft={0} scrollTop={1}", scrollLeft, scrollTop);
            double devicePixelRatio = GetWindowDevicePixelRatio();

            UtilsLog.Log("RunLoopMainStep11 devicePixelRatio={0}", devicePixelRatio);

            Point elementPosition = UtilsHtml.GetHtmlElementScreenPosition(elemreactselect5value, scrollLeft, scrollTop);

            elementPositionX  = (int)(elementPosition.X * devicePixelRatio);
            elementPositionY  = (int)(elementPosition.Y * devicePixelRatio);
            elementPositionX += 20;
            elementPositionY += 10;
            UtilsLog.Log("RunLoopMainStep11 elementPositionX={0} elementPositionY={1}", elementPositionX, elementPositionY);

            UtilsLog.Log("RunLoopMainStep11 comboBox1.SelectedIndex={0}", comboBox1.SelectedIndex);
            elementPositionY += (comboBox1.SelectedIndex + 1) * 68;

            MouseEvent.EventMouseMove(elementPositionX, elementPositionY);
            Thread.Sleep(500);
            MouseEvent.EventMouseClick(elementPositionX, elementPositionY);
            step++;
        }
Example #3
0
        private void RunLoopMainStep1()
        {
            UtilsLog.Log("RunLoopMainStep1 ENTER");

            List <HtmlElement> elems = new List <HtmlElement>();

            UtilsHtml.FindWindowHtmlElementsByTagAndText(webBrowser1.Document.Window, "button", "搜索航班", elems);
            if (elems.Count > 0)
            {
                elems[0].Focus();
                elems[0].InvokeMember("click");
                RunLoopSleep(2000);
                step++;
            }
        }
Example #4
0
        private void RunLoopMainStep7()
        {
            UtilsLog.Log("RunLoopMainStep7 ENTER");

            HtmlElement elemFlight = elemFlights[0];

            List <HtmlElement> elemFlightItems = new List <HtmlElement>();

            UtilsHtml.FindElementHtmlElements(elemFlight, ":div/:div/class:shadow-box/:div/:div/class:brand-selection-button-container/:div/:button", elemFlightItems);
            UtilsLog.Log("RunLoopMainStep7 elemFlightItems.Count={0}", elemFlightItems.Count);
            if (elemFlightItems.Count > 0)
            {
                elemFlightItems[0].Focus();
                elemFlightItems[0].InvokeMember("click");
                RunLoopSleep(2000);
                step++;
            }
        }
Example #5
0
        private void RunLoopMainStep6()
        {
            UtilsLog.Log("RunLoopMainStep6 ENTER");

            HtmlElement elemFlight = elemFlights[0];

            List <HtmlElement> elemFlightItems = new List <HtmlElement>();

            UtilsHtml.FindElementHtmlElements(elemFlight, ":div/:div/:div/class:itinerary-part-offer-price/class:price-content-wrapper/data-test-id:cabin-offer-button", elemFlightItems);
            UtilsLog.Log("RunLoopMainStep6 elemFlightItems.Count={0}", elemFlightItems.Count);
            if (elemFlightItems.Count > 0)
            {
                elemFlightItems[0].Focus();
                elemFlightItems[0].InvokeMember("click");
                RunLoopSleep(2000);
                step++;
            }
        }
Example #6
0
        private void RunLoopMainStep5()
        {
            UtilsLog.Log("RunLoopMainStep5 ENTER");
            HtmlElement eledxpflighttablesection = webBrowser1.Document.GetElementById("dxp-flight-table-section");

            if (eledxpflighttablesection == null)
            {
                return;
            }

            elemFlights.Clear();
            foreach (HtmlElement eledxpflighttablesectionChild in eledxpflighttablesection.Children)
            {
                string eledxpflighttablesectionChildClassName = eledxpflighttablesectionChild.GetAttribute("className");
                if (eledxpflighttablesectionChildClassName.Contains("ducp-component-panel") &&
                    eledxpflighttablesectionChildClassName.Contains("spark-panel") &&
                    eledxpflighttablesectionChildClassName.Contains("itinerary-part-offer"))
                {
                    elemFlights.Add(eledxpflighttablesectionChild);
                }
            }

            if (elemFlights.Count > 0)
            {
                if (comboBox2.Text == "商务舱")
                {
                    HtmlElement        elemFlight      = elemFlights[0];
                    List <HtmlElement> elemFlightItems = new List <HtmlElement>();
                    UtilsHtml.FindElementHtmlElements(elemFlight, ":div/:div/:div/:button", elemFlightItems);
                    foreach (HtmlElement elemFlightItem in elemFlightItems)
                    {
                        if (elemFlightItem.InnerText.Contains("下一個"))
                        {
                            elemFlightItem.Focus();
                            elemFlightItem.InvokeMember("click");
                        }
                    }
                }

                RunLoopSleep(2000);
                step++;
            }
        }
Example #7
0
        private HtmlElement FindFlightContent()
        {
            HtmlElement elemapp = webBrowser1.Document.GetElementById("app");

            if (elemapp != null)
            {
                List <HtmlElement> elemappItems = new List <HtmlElement>();
                UtilsHtml.FindElementHtmlElements(elemapp, ":div/:div", elemappItems);
                foreach (HtmlElement elemappItem in elemappItems)
                {
                    string elemappItemClassName = elemappItem.GetAttribute("className");
                    if (elemappItemClassName != null && elemappItemClassName.Contains("flight-content"))
                    {
                        return(elemappItem);
                    }
                }
            }

            return(null);
        }
Example #8
0
        private void RunLoopMainStep8()
        {
            UtilsLog.Log("RunLoopMainStep8 ENTER");

            HtmlElement eledxpsharedflightselection = webBrowser1.Document.GetElementById("dxp-shared-flight-selection");

            if (eledxpsharedflightselection != null)
            {
                List <HtmlElement> eledxpsharedflightselectionItems = new List <HtmlElement>();
                UtilsHtml.FindElementHtmlElements(eledxpsharedflightselection, ":div/:div/:button", eledxpsharedflightselectionItems);
                UtilsLog.Log("RunLoopMainStep8 eledxpsharedflightselection.Count={0}", eledxpsharedflightselectionItems.Count);
                foreach (HtmlElement eledxpsharedflightselectionItem in eledxpsharedflightselectionItems)
                {
                    if (eledxpsharedflightselectionItem.InnerText == "乘客")
                    {
                        eledxpsharedflightselectionItem.Focus();
                        eledxpsharedflightselectionItem.InvokeMember("click");
                        RunLoopSleep(2000);
                        step++;
                    }
                }
            }
        }