Exemple #1
0
        /// <summary>
        /// Launches the browser.
        /// </summary>
        /// <param name="browser">The browser.</param>
        /// <param name="uri">The URI.</param>
        public void Start(BrowserModel browser, Uri uri)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }

            StartServer();

            string browserStr = Enum <BrowserModel> .Value(browser);

            _selenium = new DefaultSelenium(_serverHost, _serverPort, browserStr, uri.AbsoluteUri);

            _selenium.Start();
            _selenium.WindowFocus();
            //_selenium.WindowMaximize();
            _selenium.Open("/");
            _selenium.WaitForPageToLoad("50000");
        }
        ///<summary>
        /// This method creates a customer with the same details of a self exclusion customer
        /// <example>RegisterCustomer_selfExclusion(portalbrowser, adminbrowser) </example>
        public void RegisterCustomer_selfExclusion(ISelenium browser, ISelenium adminBrowser)
        {
            try
            {
                string regMsg, gender, xPath;
                var admincommonObj = new AdminSuite.Common();
                Random rnd = new Random();
                int rndNumber = rnd.Next(10000);

                //get details of customer in OB
                adminBrowser.WindowFocus();
                string username = "******" + rndNumber;
                admincommonObj.SelectMainFrame(adminBrowser);
                string firstname = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'First Name:')]/following-sibling::td");
                string lastname = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Last Name:')]/following-sibling::td");
                string title = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Title:')]/following-sibling::td");
                if (title.ToLower() == "mr")
                {
                    gender = "male";
                }
                else
                {
                    gender = "female";
                }

                string dob = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Date of Birth:')]/following-sibling::td");
                string[] arr = dob.Split('-');
                string DOByear = arr[0];
                System.Globalization.DateTimeFormatInfo mfi = new System.Globalization.DateTimeFormatInfo();
                string DOBmonth = mfi.GetMonthName(int.Parse(arr[1])).ToString();
                string DOBday = arr[2];

                string houseno = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Address (1)')]/following-sibling::td");
                string postcode = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Postcode:')]/following-sibling::td");

                string address1 = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), '(2)')]/following-sibling::td") + adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), '(3)')]/following-sibling::td");
                string address2 = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), '(3)')]/following-sibling::td");
                string city = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'City:')]/following-sibling::td");
                string email = adminBrowser.GetText("//tr/td[@class='caption' and contains(text(), 'Email:')]/following-sibling::td");
                string teleCode = "+44";
                string telnumber = "1234567890";
                string mobnumber = "1234512345";

                string password = "******";
                string confirmPassword = "******";
                string securityQuestion = "Favourite Colour";
                string securityAnswer = "Blue";

                string accountCurrency = "UK Pound Sterling";
                string country = "United Kingdom";

                browser.WindowFocus();
                WaitForLoadingIcon_MobileLobby(browser, FrameGlobals.IconLoadTimeout);
                Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration Page is not displayed");

                //Enter data in all the fields
                browser.Type(MobileLobbyControls.promocode, "");
                browser.Select(MobileLobbyControls.title, title);
                browser.Type(MobileLobbyControls.firstname, firstname);
                browser.Type(MobileLobbyControls.lastname, lastname);
                //gender
                if (gender.ToLower().Trim() == "male")
                {
                    browser.Click(MobileLobbyControls.genderMale);
                }
                else
                {
                    browser.Click(MobileLobbyControls.genderFemale);
                }

                browser.Select(MobileLobbyControls.DOBday, DOBday);
                browser.Select(MobileLobbyControls.DOBmonth, DOBmonth);
                browser.Select(MobileLobbyControls.DOByear, DOByear);
                browser.Select(MobileLobbyControls.country, country);

                browser.Type(MobileLobbyControls.housename, houseno);
                browser.Type(MobileLobbyControls.postcode, postcode);
                browser.Type(MobileLobbyControls.address1, address1);
                browser.Type(MobileLobbyControls.address2, address2);
                browser.Type(MobileLobbyControls.city, city);
                browser.Type(MobileLobbyControls.email, email);

                browser.Type(MobileLobbyControls.telintcode, teleCode);
                browser.Type(MobileLobbyControls.telnumber, telnumber);
                browser.Type(MobileLobbyControls.mobintcode, teleCode);
                browser.Type(MobileLobbyControls.mobnumber, mobnumber);
                browser.Select(MobileLobbyControls.accountCurrency, accountCurrency);

                browser.Type(MobileLobbyControls.username, username);
                browser.Type(MobileLobbyControls.password, password);
                browser.Type(MobileLobbyControls.confirmPassword, confirmPassword);
                browser.Select(MobileLobbyControls.securityQuestion, securityQuestion);
                browser.Type(MobileLobbyControls.securityAnswer, securityAnswer);
                MLcommonObj.SelectCheckbox(browser, MobileLobbyControls.contactMe, "on");
                MLcommonObj.SelectCheckbox(browser, MobileLobbyControls.aggreement, "on");
                Thread.Sleep(1000);

                //Validate registration
                clickObject_MobileLobby(browser, MobileLobbyControls.registerNow);
                Assert.IsTrue(browser.IsVisible(MobileLobbyControls.registrationTitle), "Registration page title was not found in the header after registration");
                Assert.IsTrue(browser.IsVisible(MobileLobbyControls.failureRgMsg), "Registration failure message was not displayed");

                regMsg = "We are sorry but your country of residence is currently prohibited from using the Ladbrokes service.";
                xPath = "//ul[@class='error_align']/li[contains(text()[2], '" + regMsg + "')]";
                Assert.IsTrue(browser.IsElementPresent(xPath), "Registration failure message was not displayed to the user");
                Assert.IsTrue(browser.IsVisible(MobileLobbyControls.contactMessage), "Customer contact message was not displayed on failing to create a  customer from banned country");
                Console.WriteLine("Customer was not registered as his details provided matched a self excluded customer");
            }
            catch (Exception ex)
            {
                CaptureScreenshot(browser, "EnterRegisterDetails");
                Console.WriteLine("Function 'EnterRegisterDetails' - Failed");
                Console.WriteLine(ex.Message);
                Fail(ex.Message);
            }
        }
            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());
                }
            }