Пример #1
0
 public virtual void Quit()
 {
     try{
         if (MyBrowser != null)
         {
             MyBrowser.Close();
         }
     }
     catch (Exception) { }
 }
        ///<summary>
        /// This method Clicks on the NRF links and validates the URl opened in the new browser
        /// <example>ValidatePopupsofNFR(MyBrowser, "xPath", "Ladbrokes LBR", "https://www.gibraltar.gov.gi/remotegambling");
        public void ValidatePopupsofNFR(ISelenium browser, string xPath, string newWindowTitle, string expURL)
        {
            try
            {
                browser.Click(xPath);
                HGframeworkCommonObj.PageSync(browser);
                HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                Thread.Sleep(1000);
                Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + xPath + "' link");
                Assert.IsTrue(browser.IsTextPresent("You are about to navigate away from the site and any selections you have in the betslip may be lost"), "Warning message[1] is not displayed in the Alert container");
                Assert.IsTrue(browser.IsTextPresent("Do you want to navigate away?"), "Warning message[2] is not displayed in the Alert container");
                browser.Click(LoginLogoutControls.CloseButtonInAlertContainer);
                HGframeworkCommonObj.PageSync(browser);
                Assert.IsFalse(browser.IsVisible(LoginLogoutControls.alertContainer), "Alert container failed to close on tapping the Cancel button");

                browser.Click(xPath);
                HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                Thread.Sleep(1000);
                Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + xPath + "' link");
                browser.Click(LoginLogoutControls.ContinueButtonInAlertContainer);
                HGframeworkCommonObj.PageSync(browser);
                Thread.Sleep(2000);
                HGFcommonObj.SwitchWindow(browser, newWindowTitle);

                string actUrl = browser.GetLocation();
                // url = driver.Url;
                browser.Close();
                browser.SelectWindow("null");
                Thread.Sleep(1000);

                if (actUrl.ToLower().Trim() != expURL.ToLower().Trim())
                {
                    Console.WriteLine("Mismatch in URL's. Actual '" + actUrl + "',  Expected '" + expURL + "'.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Function 'ValidatePopupsofNFR' - Failed");
                Console.WriteLine(ex.Message);
                Fail(ex.Message);
            }
        }
Пример #3
0
        }//end ClearTest

        ///<summary>
        ///Grab warrant data from http://www.hkex.com.hk/eng/dwrc/newissue/newlaunch.htm
        ///</summary>
        ///<returns> void </returns>
        private void WarrantDataCapture()
        {
            int start_position = startPosition;

            try
            {
                selenium1.OpenWindow("/eng/dwrc/newissue/newlaunch.htm", "WarrantListWindow");
                selenium1.WaitForPopUp("WarrantListWindow", "30000");
                selenium1.SelectWindow("WarrantListWindow");

                //Get English Content
                //while (selenium1.IsElementPresent("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[1]"))
                while (start_position <= endPosition && selenium1.IsElementPresent("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[1]"))
                {
                    String   launchDateStr    = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[11]");
                    DateTime tempLaunchDateDT = DateTime.ParseExact(launchDateStr, "dd-MM-yyyy", null);
                    DateTime temp             = coreObj.DateCalculate(scheduleDate, tempLaunchDateDT, holidayCount);

                    if (temp.Date == scheduleDate.Date)
                    {
                        HKRicTemplate hkRic = new HKRicTemplate();
                        hkRic.launchDateDT        = DateTime.ParseExact(launchDateStr, "dd-MM-yyyy", null);
                        hkRic.ricCodeStr          = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[2]");
                        hkRic.ricNameStr          = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[3]");
                        hkRic.issuerIDStr         = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[4]");
                        hkRic.underlyingStr       = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[5]");
                        hkRic.callPutStr          = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[6]");
                        hkRic.boardLotStr         = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[7]");
                        hkRic.strikeLevelStr      = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[8]");
                        hkRic.entitlementRatioStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[9]");
                        hkRic.issueSizeStr        = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[10]");
                        hkRic.clearingCommDateDT  = DateTime.ParseExact(selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[12]"), "dd-MM-yyyy", null);
                        hkRic.listingDateDT       = DateTime.ParseExact(selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[13]"), "dd-MM-yyyy", null);
                        hkRic.maturityDateDT      = DateTime.ParseExact(selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[14]"), "dd-MM-yyyy", null);


                        //Get issue price
                        String url        = selenium1.GetAttribute("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[2]/a@href");
                        String id         = url.Substring(url.IndexOf('=') + 1, 5);
                        String summaryUrl = "http://www.hkex.com.hk/eng/dwrc/dwsummary.asp?id=" + id;
                        selenium1.OpenWindow(summaryUrl, "WarrantSummaryWindow" + start_position);
                        selenium1.WaitForPopUp("WarrantSummaryWindow" + start_position, "30000");
                        selenium1.SelectWindow("WarrantSummaryWindow" + start_position);

                        //For Equity Get underlying name
                        if (Char.IsDigit(hkRic.underlyingStr, 0))
                        {
                            hkRic.underlyingNameForStockStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr[3]/td[2]").Substring(8);
                        }

                        hkRic.issuePriceStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr[11]/td[2]").Substring(4);

                        selenium1.Close();

                        ricList.Add(hkRic);


                        selenium1.SelectWindow("WarrantListWindow");
                    }//end if

                    start_position++;
                }//end while

                ChineseNameCapture(start_position);

                //Get gearing and premium
                //search on page http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.asp
                DataCaptureFromPDF(0);
            }//end try
            catch (SeleniumException ex)
            {
                String errLog = ex.ToString();
                selenium1.Close();
                selenium1.Stop();
                CaptureRetry(start_position);
            }
        }//end WarrantDataCapture()
        private void uploadFile(int i)
        {
            StartRC();
            i++;
            try
            {
                selenium.Open("/GEDA15/index.html");
                selenium.WaitForPageToLoad("50000");
                selenium.Type("username", "YQ_LI");
                selenium.Type("password", "Reuters5");
                //selenium.Click("ext-gen27");
                selenium.Click("//button[@class=' x-btn-text'][text()='Login']");
                selenium.WaitForPageToLoad("50000");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=img.x-tree-ec-icon.x-tree-elbow-end-plus");
                System.Threading.Thread.Sleep(2000);
                selenium.DoubleClick("//ul[@class='x-tree-node-ct']/li[@class='x-tree-node']/descendant::a[@class='x-tree-node-anchor']/span[text()='Message Editor']");
                selenium.SelectFrame("IFFMEditor");
                System.Threading.Thread.Sleep(4000);

                //Upload the first file
                selenium.Click("ext-gen163");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_BULK']");
                selenium.Click("ext-gen168");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=#ext-gen182 > div.x-combo-list-item");
                selenium.Click("//button[@class=' x-btn-text search'][text()='Search']");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']");
                System.Threading.Thread.Sleep(2000);
                selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLB.txt");
                System.Threading.Thread.Sleep(3000);
                //Upload
                selenium.Click("//button[@class=' x-btn-text'][text()='Upload']");
                System.Threading.Thread.Sleep(2000);
                //Ok
                selenium.Click("//button[@class=' x-btn-text'][text()='OK']");
                System.Threading.Thread.Sleep(3000);

                //Upload the second file
                selenium.Click("ext-gen163");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_CBBC1']");
                selenium.Click("ext-gen168");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=#ext-gen182 > div.x-combo-list-item");
                selenium.Click("//button[@class=' x-btn-text search'][text()='Search']");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']");
                System.Threading.Thread.Sleep(2000);
                selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLB_CBBC.txt");
                System.Threading.Thread.Sleep(2000);
                //Upload
                selenium.Click("//button[@class=' x-btn-text'][text()='Upload']");
                System.Threading.Thread.Sleep(2000);
                //Ok
                selenium.Click("//button[@class=' x-btn-text'][text()='OK']");
                System.Threading.Thread.Sleep(3000);

                //Upload the third file
                selenium.Click("ext-gen163");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_EQLBMI']");
                selenium.Click("ext-gen168");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("css=#ext-gen182 > div.x-combo-list-item");
                selenium.Click("//button[@class=' x-btn-text search'][text()='Search']");
                System.Threading.Thread.Sleep(2000);
                selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']");
                System.Threading.Thread.Sleep(2000);
                selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLBMI.txt");
                System.Threading.Thread.Sleep(2000);
                //Upload
                selenium.Click("//button[@class=' x-btn-text'][text()='Upload']");
                System.Threading.Thread.Sleep(2000);
                //Ok
                selenium.Click("//button[@class=' x-btn-text'][text()='OK']");

                selenium.Close();
                selenium.Stop();
            }
            catch (SeleniumException ex)
            {
                if (ex.Message.Contains("Timed out") && i < 4)
                {
                    uploadFile(i);
                }

                MessageBox.Show(ex.Message);
                selenium.Close();
                selenium.Stop();
            }
        }
Пример #5
0
 public void Close()
 {
     selenium.Close();
 }
 public void Test_Dispose()
 {
     selenium.SetTimeout("100000");
     selenium.Open("Admin/Tests/Dispose.aspx");
     selenium.Close();
 }
        ///<summary>
        /// This method verifies the all the policies on Home page 
        /// <example>VerifyPolicies(MyBrowser)</example>  
        public void VerifyPolicies(ISelenium browser, string[] Policies, string[] URLs)
        {
            try
            {
                string url, xPath;
                for (int i = 0; i < Policies.Length; i++)
                {
                    HGframeworkCommonObj.PageSync(browser);
                    xPath = "//a[starts-with(@class, 'bxc tac sec-button small footer') and contains(text(), '" + Policies[i] + "')]";

                    Assert.IsTrue(browser.IsElementPresent(xPath), Policies[i] + " button not found");
                    browser.Click(xPath);
                    HGframeworkCommonObj.PageSync(browser);
                    HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                    Thread.Sleep(1000);
                    Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + Policies[i] + "' link");
                    Assert.IsTrue(browser.IsTextPresent("You are about to navigate away from the site and any selections you have in the betslip may be lost"), "Warning message[1] is not displayed in the Alert container");
                    Assert.IsTrue(browser.IsTextPresent("Do you want to navigate away?"), "Warning message[2] is not displayed in the Alert container");
                    browser.Click(LoginLogoutControls.CloseButtonInAlertContainer);
                    HGframeworkCommonObj.PageSync(browser);
                    Assert.IsFalse(browser.IsVisible(LoginLogoutControls.alertContainer), "Alert container failed to close on tapping the Cancel button");

                    browser.Click(xPath);
                    HGframeworkCommonObj.WaitUntilElementPresent(browser, LoginLogoutControls.alertContainer, "5000");
                    Thread.Sleep(1000);
                    Assert.IsTrue(browser.IsElementPresent(LoginLogoutControls.alertContainer), "Alert container was not displayed on tapping the '" + Policies[i] + "' link");
                    browser.Click(LoginLogoutControls.ContinueButtonInAlertContainer);
                    HGframeworkCommonObj.PageSync(browser);
                    Thread.Sleep(2000);

                    //Title is different for Desktop policy
                    if (Policies[i] == "Desktop")
                    {
                        HGFcommonObj.SwitchWindow(browser, "Ladbrokes Mobile");
                    }
                    else
                    {
                        HGFcommonObj.SwitchWindow(browser, "LBR Customer KB");
                    }

                    url = browser.GetLocation();
                    // url = driver.Url;
                    browser.Close();
                    browser.SelectWindow("null");
                    Thread.Sleep(1000);

                    if (url.ToLower().Trim() == URLs[i].ToLower().Trim())
                    {
                        Console.WriteLine("'" + Policies[i] + "' validated successfully");
                    }
                    else
                    {
                        Console.WriteLine("Failed to validate the '" + Policies[i] + "'");
                        Fail("Mismatch in Actual and Expected URLs");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Function 'VerifyPolicies' - Failed");
                Console.WriteLine(ex.Message);
                Fail(ex.Message);
            }
        }