Exemplo n.º 1
0
        public string GetAttribute(string attributeLocator)
        {
            bool actRes = false; string errStr = "", resStr = "";

            try
            {
                resStr = selenium.GetAttribute(attributeLocator);
                actRes = true;
            }
            catch (System.Exception ex)
            {
                errStr = ex.ToString();
            }

            res = new ResultClass()
            {
                Decp = "GetAttribute, " + attributeLocator,
                Res  = actRes ? "pass" : "fail",
                Tdev = " ms",
                Err  = errStr,
            };
            BaseListOfResItems.Add(res);

            return(resStr);
        }
Exemplo n.º 2
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()
Exemplo n.º 3
0
            public void TestUpload([Values("BathroomFixtures02.zip",
                                           "Bidet02.zip",
                                           "BlockTable02.zip",
                                           "Chandleir01.zip",
                                           "Chandleir03.zip",
                                           "ClassicDresser02.zip",
                                           "ClassicWoodCoffeeTable02.zip",
                                           "CoffeeTAble02.zip",
                                           "Console02.zip",
                                           "Console03.zip",
                                           "DeskLamp02.zip",
                                           "DinnerChair with arms02.zip",
                                           "DinnerChair01.zip",
                                           "DinnerChair02.zip",
                                           "DirectorsChair02.zip",
                                           "Dresser02.zip",
                                           "EasyChair02.zip",
                                           "EasyChair03.zip",
                                           "EasyChair04.zip",
                                           "ElegantCouch02.zip",
                                           "FloorLamp01.zip",
                                           "FloorLamp03.zip",
                                           "GreenChair02.zip",
                                           "GreenCouch02.zip",
                                           "Grill02.zip",
                                           "Lamp01.zip",
                                           "Lamp02.zip",
                                           "Lamp03.zip",
                                           "LargeChaise02.zip",
                                           "MetalDiningChair02.zip",
                                           "MetalDinnerChairArms02.zip",
                                           "MetalExteriorChair02.zip",
                                           "MetalPoolChair02.zip",
                                           "Microwave02.zip",
                                           "MissionTable01.zip",
                                           "MissionTable02.zip",
                                           "ModernCeilingLight02.zip",
                                           "ModernConsoleTable02.zip",
                                           "ModernEasyChair02.zip",
                                           "ModernEndTable02.zip",
                                           "ModernFloorLamp02.zip",
                                           "ModernHangingLight02.zip",
                                           "ModernSconce01.zip",
                                           "ModernSconce02.zip",
                                           "OfficeChair02.zip",
                                           "OutdoorChair02.zip",
                                           "OvenFront02.zip",
                                           "PlushCouch02.zip",
                                           "RectangularAutoman02.zip",
                                           "RollingChaise02.zip",
                                           "RoundAutoman02.zip",
                                           "RoundEndTable01.zip",
                                           "RoundEndTable02.zip",
                                           "Sconce02.zip",
                                           "ServingTrayTable02.zip",
                                           "SquareLamp02.zip",
                                           "Stool02.zip",
                                           "TableLamp02.zip",
                                           "Tent 02.zip",
                                           "Tent02.zip",
                                           "Toilet02.zip",
                                           "Umbrella 01.zip",
                                           "Umbrella01.zip",
                                           "Umbrella03.zip",
                                           "WickerAutoman02.zip",
                                           "WickerChair02.zip",
                                           "WickerCouch02.zip",
                                           "WickerOutdoorLoveseat02.zip",
                                           "WingBackChair02.zip",
                                           "WoodAndMetalCoffeeTable02.zip",
                                           "WoodAndMetalDinnerTable01.zip",
                                           "WoodAndMetalDinnerTable02.zip",
                                           "WoodenDresser02.zip",
                                           "WoodEndTable02.zip")]  string filename)
            {
                selenium.WindowMaximize();
                selenium.Open("/Default.aspx");
                selenium.WindowFocus();

                if (!UserLoggedIn)
                {
                    Login();
                }

                selenium.WaitForPageToLoad("30000");
                selenium.Open("/Users/Upload.aspx");
                selenium.WaitForPageToLoad("30000");

                path = _3DR_Testing.Properties.Settings.Default.ContentPath;
                if (String.IsNullOrEmpty(filename))
                {
                    verificationErrors.Append("Error, filename to be upload cannot be blank.");
                    return;
                }
                else if (!File.Exists(path + filename))
                {
                    verificationErrors.Append("Error, " + path + filename + " could not be found");
                    return;
                }


                bool uploadResult = UploadFile(path + filename, UploadButtonIdentifier.MODEL_UPLOAD);

                if (!uploadResult)
                {
                    return;
                }

                string windowHandle  = "selenium.browserbot.getCurrentWindow()";
                string currentFormat = "";

                try
                {
                    selenium.WaitForCondition(windowHandle + ".MODE != ''", "20000");
                    currentFormat = selenium.GetEval(windowHandle + ".MODE");
                    string formatDetectStatus = selenium.GetText("id=formatDetectStatus");
                    int    substringIndex     = formatDetectStatus.LastIndexOf("Format Detected:");
                    switch (currentFormat)
                    {
                    case "VIEWABLE":
                        Assert.GreaterOrEqual(substringIndex, 0);
                        selenium.WaitForCondition(windowHandle + ".ModelConverted == true", "120000");
                        string conversionStatus = selenium.GetText("id=conversionStatus");
                        if (conversionStatus != "Conversion Failed")
                        {
                            Assert.AreEqual("Model Ready for Viewer", conversionStatus);
                            break;
                        }
                        else
                        {
                            return;      //Conversion failed, test has ended
                        }

                    case "RECOGNIZED":
                        Assert.GreaterOrEqual(substringIndex, 0);
                        break;

                    case "MULTIPLE_RECOGNIZED":
                        Assert.AreEqual("Multiple Models Detected", formatDetectStatus);
                        return;     //We have multiple recognized models, so the test has ended

                    case "UNRECOGNIZED":
                        Assert.AreEqual("Unrecognized Format", formatDetectStatus);
                        return;     //Unrecognized format, test has ended

                    default:
                        Assert.AreEqual("Server Error", formatDetectStatus);
                        return;     //Invalid server response, test has ended
                    }
                }
                catch (SeleniumException e)
                {
                    throw new NUnit.Framework.InconclusiveException(e.Message);
                }

                string title = String.Format("Automatic Upload of {0} at {1}",
                                             filename,
                                             DateTime.Now.ToString());

                selenium.Type("id=ctl00_ContentPlaceHolder1_Upload1_TitleInput", title);
                selenium.Type("id=ctl00_ContentPlaceHolder1_Upload1_DescriptionInput", FormDefaults.Description);
                selenium.Type("id=ctl00_ContentPlaceHolder1_Upload1_TagsInput", FormDefaults.Tags);

                string nextButtonDisplay = selenium.GetEval(windowHandle + ".jQuery('#nextbutton_upload').css('display')");

                Assert.AreEqual("block", nextButtonDisplay);

                selenium.Click("id=nextbutton_upload");
                Thread.Sleep(3000);
                string imageFileName = path + FormDefaults.ScreenshotFilename;//GetImageFileName(filename);

                if (currentFormat == "VIEWABLE")
                {
                    scaleValue  = selenium.GetEval("window.g_unitscale");
                    upAxisValue = selenium.GetEval("window.g_upaxis");
                    selenium.GetEval("window.updateCamera()");
                    selenium.Click("id=SetThumbnailHeader");
                    Thread.Sleep(500);
                    selenium.Click("id=ViewableSnapshotButton");
                    selenium.WaitForCondition("var thumbnailSrc = " + windowHandle + ".jQuery('#ThumbnailPreview_Viewable').attr('src');" +
                                              "thumbnailSrc != window.thumbnailLoadingLocation && thumbnailSrc != window.previewImageLocation", "30000");
                }
                else
                {
                    if (!UploadFile(imageFileName, UploadButtonIdentifier.SCREENSHOT_RECOGNIZED))
                    {
                        return;
                    }
                }

                selenium.Click("id=nextbutton_step2");
                Thread.Sleep(3000);

                selenium.Type("id=DeveloperName", FormDefaults.DeveloperName);
                selenium.Type("id=ArtistName", FormDefaults.ArtistName);
                selenium.Type("id=DeveloperUrl", FormDefaults.DeveloperUrl);
                UploadFile(path + FormDefaults.DevLogoFilename, UploadButtonIdentifier.DEVLOGO);

                selenium.Click("id=SponsorInfoTab");

                selenium.Type("id=SponsorName", FormDefaults.SponsorName);
                UploadFile(path + FormDefaults.SponsorLogoFilename, UploadButtonIdentifier.SPONSORLOGO);

                selenium.Click("id=nextbutton_step3");
                selenium.WaitForPageToLoad("120000");

                Assert.True(selenium.IsTextPresent(FormDefaults.ArtistName));
                Assert.True(selenium.IsTextPresent(FormDefaults.DeveloperName));
                Assert.True(selenium.IsTextPresent(FormDefaults.DeveloperUrl));
                Assert.True(selenium.IsTextPresent(FormDefaults.SponsorName));
                Assert.True(selenium.IsTextPresent(FormDefaults.Description));

                int tagsCount = 0;

                string[] expectedTags = FormDefaults.Tags.Split(',');
                foreach (string s in expectedTags)
                {
                    if (selenium.IsTextPresent(s))
                    {
                        tagsCount++;
                    }
                }
                if (tagsCount < expectedTags.Length)
                {
                    throw new Exception("Not all tags were found on the details page.");
                }

                Assert.AreEqual(FormDefaults.LicenseTypeUrl, selenium.GetAttribute("ctl00_ContentPlaceHolder1_CCLHyperLink@href"));
                if (currentFormat == "VIEWABLE")
                {
                    Thread.Sleep(1000);
                    selenium.Click("xpath=//div[@id='ctl00_ContentPlaceHolder1_ViewOptionsTab']/div/ul/li[2]/a/span/span/span");
                    selenium.WaitForCondition("window.g_init == true", "60000");
                    Assert.AreEqual(scaleValue, selenium.GetEval("window.g_unitscale"));
                    Assert.AreEqual(upAxisValue.ToLower(), selenium.GetEval("window.g_upaxis").ToLower());
                }
            }