コード例 #1
0
        public void Cookie(IWebDriver driver, Datarow datrow)
        {
            try
            {
                //cookie Disclosure
                IsElementPresent(driver, By.CssSelector("div.cookieDisclosure"));
                var disclosuretext = driver.FindElement(By.CssSelector("div.cookieDisclosure")).Text;
                datrow.Newrow("Diclosure Text is Presnt",
                    "This site uses cookies. Some of the cookies we use are essential for parts of the site to operate and have already been set.",
                    disclosuretext, disclosuretext ==
                                    "This site uses cookies. Some of the cookies we use are essential for parts of the site to operate and have already been set."
                        ? "PASS"
                        : "FAIL");

                if (IsElementPresent(driver, By.Id("epdsubmit")))
                {
                    driver.FindElement(By.Id("epdsubmit")).Click();
                    datrow.Newrow("Validating 'OK' Button in cookie disclosure ", "OK button is present",
                                  "OK button is present", "PASS");
                }
                else
                {
                    datrow.Newrow("Validating 'OK' Button in cookie disclosure ", "OK button is present",
                                  "OK button is not present", "FAIL");
                }
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datrow.Newrow("Exception Not Expceted", "Not Expected", e, "FAIL");
            }
        }
コード例 #2
0
        public void Price(IWebDriver driver, Datarow datarow)
        {
            try
            {
                var pg = driver.PageSource;
                var productprice = pg.Contains("user-scalable=yes") ? CollectionMapV2.ProductPrice : CollectionMapV1.ProductPrice;

                #region Product price

                // Product Price
                if (IsElementPresent(driver, By.ClassName(productprice)))
                {
                    var price = driver.FindElement(By.ClassName(productprice)).Text;
                    datarow.Newrow("Product Price", "", price, "PASS", driver);
                }
                else if (!IsElementPresent(driver, By.Id(productprice)))
                {
                    datarow.Newrow("Product Price", "Product Price is Expected", "Element Not Identified", "FAIL",
                                   driver);
                }
                else
                {
                    datarow.Newrow("Product Price", "Product Price is Expected", "Product Is Not Displayed", "FAIL",
                                   driver);
                }

                #endregion
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            new SocialMediaSharing().Socialmediashare(driver, datarow);
        }
コード例 #3
0
        public void Batchpay(IWebDriver driver, string url, Datarow datarow)
        {
            // Payment for Physioroom

            if (url.Contains("physioroom") || url.Contains("trueshopping"))
            {
                driver.FindElement(By.XPath("//*[@id='ctl00']/section/fieldset/div[1]/label/span")).Click();
                Thread.Sleep(2000);
                driver.FindElement(By.Id("Pagecontent_ButtonCheckoutStep3")).Click();

                driver.Navigate().Back();

                driver.FindElement(By.XPath("//*[@id='ctl00']/section/fieldset/div[2]/label/span")).Click();
                Thread.Sleep(2000);
                driver.FindElement(By.Id("Pagecontent_ButtonCheckoutStep3")).Click();

                datarow.Newrow("", "", "Mopay", "", driver);
                var mopay = new MopayTps();
                mopay.Mopay(driver, datarow);
            }
            else
            {
                // This is a general payment testing using Mopay and needs to be extended if the client offering more than one payment process for example Paypal.
                datarow.Newrow("", "", "Mopay", "", driver);
                var mopay = new MopayTps();
                mopay.Mopay(driver, datarow);
            }
        }
        public void Deletebasstart(IWebDriver driver, Datarow datarow)
        {
            try
            {
                var url = driver.PageSource;
                var checkout = url.Contains("user-scalable=yes") ? CollectionMapV2.Checkout : CollectionMapV1.Checkout;

                var basket = new DeleteBasket();
                basket.Basket(driver, datarow);

                // Product unavailable
                if (!driver.PageSource.Contains("Product unavailable")) return;
                for (var l = 2;; l++)
                {
                    if (driver.PageSource.Contains("Product unavailable"))
                    {
                        datarow.Newrow("Product Unavailable", "", "Product Unavilable", "FAIL", driver);
                        _screenshot.Screenshotfailed(driver);
                        Productunavailabl(driver, l, datarow);
                        driver.FindElement(By.XPath(checkout)).Click();
                    }
                    else
                    {
                        break;
                    }
                }
            }

            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Not Expected", e, "FAIL", driver);
                _screenshot.Screenshotfailed(driver);
            }
        }
コード例 #5
0
 public void Comparedatarow(IWebDriver driver, Datarow datarow, DataTable dt)
 {
     _gereneralLibrary = new GeneralLibrary();
     var table =
         _gereneralLibrary.GetExcelData(@"C:\\Input Data\ModrophenialiveProducts.xlsx", "Products").Tables
             [0];
     for (var i = 1; i < (table.Rows.Count - 1); i++)
     {
         var actual = table.Rows[i]["Product Price"].ToString();
         var str2 = table.Rows[i]["Product Title"].ToString();
         var str3 = table.Rows[i]["Product Detail"].ToString();
         var expected = table.Rows[i]["Item Number"].ToString();
         var str5 = table.Rows[i]["Variants"].ToString();
         var str6 = dt.Rows[i]["Price"].ToString();
         var str7 = dt.Rows[i]["Title"].ToString();
         var str8 = dt.Rows[i]["Detail"].ToString();
         var str9 = dt.Rows[i]["Item Number"].ToString();
         var str10 = dt.Rows[i]["Variants"].ToString();
         datarow.Newrow(str7 + " Price", str6, actual, str6 == actual ? "PASS" : "FAIL", driver);
         datarow.Newrow(str7 + " Title", str7, str2, str7.ToUpper() == str2 ? "PASS" : "FAIL", driver);
         datarow.Newrow(str7 + " Detail", str8, str3, str8 == str3 ? "PASS" : "FAIL", driver);
         datarow.Newrow(str7 + " ItemNumber", expected, str9, expected == str9 ? "PASS" : "FAIL", driver);
         datarow.Newrow(str7 + " Variants", str5, str10,
             str5.TrimStart(new char[0]) == str10.TrimStart(new char[0]) ? "PASS" : "FAIL", driver);
     }
 }
コード例 #6
0
        public void Basket(IWebDriver driver, Datarow datarow)
        {
            try
            {
                var url = driver.PageSource;
                var deletebasket = url.Contains("user-scalable=yes") ? CollectionMapV2.Deletebasket : CollectionMapV1.Deletebasket;
                /*
                if (IsElementPresent(driver,By.XPath("//body[@id='Top']/div/div[2]/div[2]/ul/li[2]/a/span"),05))
                {
                    driver.FindElement(By.XPath("//body[@id='Top']/div/div[2]/div[2]/ul/li[2]/a/span")).Click();

                    basketvalidation(driver, datarow);
                }#
                 */
                if (IsElementPresent(driver, By.XPath(deletebasket)))
                {
                    driver.FindElement(By.XPath(deletebasket)).Click();

                    Basketvalidation(driver, datarow);
                }
                else
                {
                    datarow.Newrow("Delete From Basket", "Delete Basket Element Expected",
                                   "//ul[@id='Basket']/li/a/span" + "Element Not Present", "FAIL", driver);
                    _screenshot.Screenshotfailed(driver);
                }
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Exception Not Expected", e, "FAIL", driver);
                _screenshot.Screenshotfailed(driver);
            }
        }
コード例 #7
0
        public void Productdetail(IWebDriver driver, Datarow datarow)
        {
            string productdescription;
            string productdescriptiontab;
            string detaiL;
            var pg = driver.PageSource;

            if (pg.Contains("user-scalable=yes"))
            {
                productdescription = CollectionMapV2.ProductDescription;
                productdescriptiontab = CollectionMapV2.ProductDescriptiontab;
                detaiL = CollectionMapV2.Detail;
            }
            else
            {
                detaiL = CollectionMapV1.Detail;
                productdescription = CollectionMapV1.ProductDescription;
                productdescriptiontab = CollectionMapV1.ProductDescriptiontab;
            }

            #region Product Detail

            try
            {
                //.Click(productdescriptiontab);

                if (IsElementPresent(driver, By.XPath(productdescription)))
                {
                    var detail = driver.FindElement(By.XPath(detaiL)).Text;
                    datarow.Newrow("Product Detail", "", detail, "PASS", driver);
                }
                else if (!IsElementPresent(driver, By.XPath(productdescriptiontab)))
                {
                    datarow.Newrow("Product Detail", "Product Details Element Is Expected",
                                   "Product Detail Element Not identified", "FAIL", driver);
                }
                else
                {
                    driver.FindElement(By.XPath(productdescriptiontab)).Click();
                    if (IsElementPresent(driver, By.XPath(productdescription)))
                    {
                        var detail = driver.FindElement(By.XPath(detaiL)).Text;
                        datarow.Newrow("Product Detail", "", detail, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Product Detail", "Product Details are Expected",
                                       "Product Details Not identified", "FAIL", driver);
                    }
                }
            }
            catch (Exception)
            {
            }

            #endregion
        }
コード例 #8
0
        public void Culture(IWebDriver driver, Datarow datarow)
        {
            try
            {
                driver.FindElement(By.LinkText("MoShop")).Click();
                driver.FindElement(By.CssSelector("#IndexMenuLeaf3 > a")).Click();
                driver.FindElement(By.LinkText("testshop")).Click();
                driver.FindElement(By.LinkText("Shop")).Click();

                try
                {
                    driver.FindElement(By.CssSelector("h3.collapsible.collapsed")).Click();
                    driver.FindElement(By.CssSelector("h3.collapsible.collapsed")).Click();
                }
                catch (Exception ex)
                {
                    ex.ToString();
                }

                driver.FindElement(By.Id("CustomDomainName")).SendKeys("m.testshop.com");
                driver.FindElement(By.CssSelector("input.button")).Click();
                new SelectElement(driver.FindElement(By.Id("DefaultCultureSelected"))).SelectByText(
                    "Telugu (India) - ₹ [te-IN]");
                driver.FindElement(By.CssSelector("input.button")).Click();

                decimal count = driver.FindElements(By.XPath("//div[@id='CataloguesControl']/div/table/tbody/tr")).Count;
                for (var i = 1; i <= count; i++)
                {
                    var name = GetValue(driver,
                                           By.XPath("//div[@id='CataloguesControl']/div/table/tbody/tr[" + i +
                                                    "]/td/input"), 30);
                    if (name != "Default") continue;
                    driver.FindElement(By.XPath("//*[@id='CataloguesControl']/div/table/tbody/tr[" + i + "]/th[2]/a"))
                        .Click();
                    driver.FindElement(By.CssSelector("input.button")).Click();
                    new SelectElement(driver.FindElement(By.Id("Culture_Value"))).SelectByText(
                        "Telugu (India) - ₹ [te-IN]");
                    driver.FindElement(By.CssSelector("input.button")).Click();
                    break;
                }
                //Inserting Category Images.
                new CategoryImages().Images(driver, datarow);

                driver.Navigate().GoToUrl("http://m.testshop.com");

                var url = driver.Url;
                datarow.Newrow("Customa Domain Name", "http://m.testshop.com/", url,
                    url == "http://m.testshop.com" ? "PASS" : "FAIL", driver);
            }

            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Exception Not Exopected", e, "PASS", driver);
            }
        }
コード例 #9
0
 public void Message(IWebDriver driver, Datarow datarow)
 {
     try
     {
         IsElementPresent(driver, By.CssSelector("div.toast-title"));
         var successmessage = driver.FindElement(By.CssSelector("div.toast-title")).Text;
         datarow.Newrow("Add To Basket Success Message", "Success", successmessage, "PASS");
     }
     catch (Exception ex)
     {
         var e = ex.ToString();
         datarow.Newrow("Add To Basket Success Message", "Success", e, "FAIL");
     }
 }
コード例 #10
0
        public void click(IWebDriver driver, Datarow datarow)
        {
            try
            {
                driver.FindElement(By.XPath("//ul[@id='productList']/li/div/div/img")).Click();

                datarow.Newrow("Validating Elemnet Clickable or not", "Element should not be Clikcable",
                               "Elemenet is Clickable", "FAIL");
            }
            catch (Exception)
            {
                datarow.Newrow("Validating Elemnet Clickable or not", "Element should not be Clikcable",
                               "Elemenet is not Clickable", "PASS");
            }
        }
コード例 #11
0
        public void Mosite(IWebDriver driver, Datarow datarow, string urls, string items)
        {
            var screenshot = new Screenshot();

            var strArray = items.Split(new[] {','});
            var urlarray = urls.Split(new[] {','});
            try
            {
                foreach (var url in urlarray)
                {
                    foreach (var str in strArray.Where(str => str != null))
                    {
                        if (str == "Test All Links in Mosite")
                        {
                            datarow.Newrow("", "", "Test All Links in Mosite", "", driver);
                            var tick = new Tickle();
                            tick.HomepageTabsTickle(datarow, driver, url);
                        }

                        if (str == "Test Footer Links")
                        {
                            datarow.Newrow("", "", "Test Footer Links", "", driver);
                        }
                        if (str == "Test Basket Functionality")
                        {
                            datarow.Newrow("", "", "Test Basket Functionality", "", driver);
                        }
                        if (str == "Test Produict Page - Test Add Product to Basket")
                        {
                            datarow.Newrow("", "", "Test Produict Page - Test Add Product to Basket", "", driver);
                        }
                        if (str == "Test Delete From Basket - Test Product Unavailable")
                        {
                            datarow.Newrow("", "", "Test Delete From Basket - Test Product Unavailable", "", driver);
                        }
                        if (str == "Test Registration/Login - CheckOut Pages")
                        {
                            datarow.Newrow("", "", "Test Registration/Login - CheckOut Pages", "", driver);
                        }
                        if (str == "Test Mopay")
                        {
                            datarow.Newrow("", "", "Test Mopay", "", driver);
                        }
                    }
                }
            }
            catch (Exception)
            {
                datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver);
                screenshot.Screenshotfailed(driver);
            }
            finally
            {
                datarow.Excelsave("MoshopConsole", driver, "*****@*****.**");
                screenshot.Screenshotfailed(driver);
                driver.Quit();
            }
        }
コード例 #12
0
        public void HomepageTabsTickle(Datarow datarow, IWebDriver driver, string url)
        {
            try
            {
                driver.Navigate().GoToUrl(url);

                Thread.Sleep(0xbb8);
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0));
                driver.FindElement(By.XPath("//body[@id='page-home-index']/div/div[2]/div/ul/li/div/div/a/h2"));
                driver.FindElement(By.XPath("//body[@id='page-home-index']/div/div[2]/div/ul/li/div/div/a/h2")).Click();

                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0));
                driver.FindElement(
                    By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/h2"));
                driver.FindElement(By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/h2"))
                      .Click();

                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0));
                driver.FindElement(By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/p"));
                driver.FindElement(By.XPath("//body[@id='page-categories-details']/div/div[2]/div/ul/li/div/div/a/p"))
                      .Click();
            }
            catch (Exception exception)
            {
                var actual = exception.ToString();
                datarow.Newrow("Exception", "Not Expected", actual, "FAIL", driver);
            }
        }
コード例 #13
0
 public void Links(Datarow datarow, IWebDriver driver, string url)
 {
     try
     {
         if (url.Contains("user-scalable=yes"))
         {
             var link = new LinksExpand();
             link.AllLink(driver, datarow);
             //Productpage page = new Productpage();
             // page.productPage(driver, datarow);
         }
         else
         {
             var link = new LinksExpand();
             link.AllLink(driver, datarow);
             //  Productpage page = new Productpage();
             // page.productPage(driver, datarow);
         }
     }
     catch(Exception ex)
     {
         var e = ex.ToString();
         datarow.Newrow("Exception", "Exception Not Exopected", e, "FAIL");
     }
 }
コード例 #14
0
        public void Runscrape(IWebDriver driver, Datarow datarow)
        {
            try
            {
                driver.FindElement(By.LinkText("Execute")).Click();

                try
                {
                    Selectanoption(driver, By.Id("TestCatalogueId"), "testshop (Default)");
                }
                catch (Exception)
                {
                    Selectanoption(driver, By.Id("TestCatalogueId"), "testshop (0.1)");
                }

                //new SelectElement(driver.FindElement(By.Id("TestCatalogueId"))).SelectByText("Default");
                driver.FindElement(By.Name("PostAction[]")).Click();

                var title = driver.Title;
                Scarperead(driver, datarow, title);
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Excepion Not Expected", e, "FAIL", driver);
            }
        }
コード例 #15
0
        public void Wolfordcheckout(IWebDriver driver, Datarow datarow)
        {
            try
            {
                var page1 = driver.Url;
                datarow.Newrow("Reached the custom Checkout Page", "", page1, "");
                driver.FindElement(By.Id("Pagecontent_ButtonGuest")).Click();

                driver.FindElement(By.Id("Pagecontent_TextBoxFirstName")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxFirstName")).SendKeys("Test");
                driver.FindElement(By.Id("Pagecontent_TextBoxLastname")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxLastname")).SendKeys("Test");
                driver.FindElement(By.Id("Pagecontent_TextBoxHouseNumber")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxHouseNumber")).SendKeys("27");
                driver.FindElement(By.Id("Pagecontent_TextBoxStreet")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxStreet")).SendKeys("Ross Road");
                driver.FindElement(By.Id("Pagecontent_TextBoxCity")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxCity")).SendKeys("Twickenham");
                driver.FindElement(By.Id("Pagecontent_TextBoxPostCode")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxPostCode")).SendKeys("tw2 6jr");
                driver.FindElement(By.Id("Pagecontent_TextBoxEmail")).SendKeys("*****@*****.**");
                driver.FindElement(By.Id("Pagecontent_TextBoxDOB")).Clear();
                driver.FindElement(By.Id("Pagecontent_TextBoxDOB")).SendKeys("13.08.1984");
                driver.FindElement(By.Id("Pagecontent_ButtonContinue")).Click();

                var page2 = driver.Url;
                datarow.Newrow("Reached the Delivery Checkout Page", "", page2, "");
                //Free Delivery
                //driver.FindElement(By.XPath("//fieldset[@id='__sizzle__']/div[2]/label/span/span")).Click();
                driver.FindElement(By.Id("Pagecontent_ButtonCheckoutStep2")).Click();

                var page3 = driver.Url;
                datarow.Newrow("Reached the Confirm Page to Accept Terms and Conditions", "", page3, "");
                //terms and conditions
                driver.FindElement(By.XPath("//label[@id='lblTnc']/span")).Click();
                driver.FindElement(By.Id("Pagecontent_ButtonConfirmCheckout")).Click();

                Assert.AreEqual("Checkout - Wolford UK", driver.Title);
                var page4 = driver.Url;
                datarow.Newrow("Reached the Payment Page", "", page4, "");
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Exception Not Exopected", e, "FAIL");
            }
        }
コード例 #16
0
        public void Scarperead(IWebDriver driver, Datarow datarow, string job)
        {
            var j = 1;
            for (var i = 0;; i++)
            {
                if (IsElementPresent(driver, By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[2]"), 30))
                {
                    try
                    {
                        var title =
                            driver.FindElement(By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[2]")).Text;
                        var type = driver.FindElement(By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[3]")).Text;
                        var startson =
                            driver.FindElement(By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[4]")).Text;
                        var action =
                            driver.FindElement(By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[5]")).Text;

                        datarow.Newrow("Scarpe Tilte", "", title, "PASS", driver);
                        datarow.Newrow("Scarpe Type", "", type, "PASS", driver);
                        Thread.Sleep(5000);
                        driver.Navigate().Refresh();

                        break;
                    }
                    catch (Exception ex)
                    {
                        var e = ex.ToString();
                        datarow.Newrow("Exception", "Excepion Not Expected", e, "FAIL", driver);
                    }
                }
                else
                {
                    Thread.Sleep(5000);
                    driver.Navigate().Refresh();

                    j++;
                }
                if (j != 10) continue;
                datarow.Newrow("Scarpe/Datafeed Start", "Scarpe/Datafeed should start",
                    "Scarpe/Datafeed didnt start after 60 sec", "FAIL", driver);
                break;
            }
            driver.FindElement(By.LinkText("Running")).Click();

            Scrapeandfeedrunning(driver, datarow);
        }
コード例 #17
0
        public void CheckouT(IWebDriver driver, Datarow datarow)
        {
            try
            {
                driver.FindElement(By.LinkText("Checkout")).Click();

                datarow.Newrow("", "", "CHECKOUT", "", driver);
                var actual = driver.Title;
                if (actual == "Checkout : mobank.co.uk/MoShop")
                {
                    datarow.Newrow("Checkout Title", "Checkout : mobank.co.uk/MoShop", actual, "PASS", driver);
                }
                else
                {
                    datarow.Newrow("Checkout Title", "Checkout : mobank.co.uk/MoShop", actual, "PASS", driver);
                }
                Thread.Sleep(3000);
                driver.FindElement(By.Id("CheckoutProcesses_0__Name")).Clear();
                driver.FindElement(By.Id("CheckoutProcesses_0__Name")).SendKeys("Tickle (copy of QA by SB)");
                driver.FindElement(By.Id("CheckoutProcesses_0__Name")).SendKeys(Keys.Enter);

                driver.FindElement(By.Id("GenerateUniqueReference")).Click();
                driver.FindElement(By.Id("PaymentAccountIdentifier")).Clear();
                driver.FindElement(By.Id("PaymentAccountIdentifier")).SendKeys("45af07ff-a7dc-4453-89b0-285b85deef2a");
                driver.FindElement(By.CssSelector("input.button")).Click();

                Thread.Sleep(3000);
                var attribute = driver.FindElement(By.Id("CheckoutProcesses_0__Name")).GetAttribute("Value");
                if (attribute == "")
                {
                    driver.FindElement(By.Id("CheckoutProcesses_0__Name")).SendKeys("Tickle (copy of QA by SB)");
                    driver.FindElement(By.CssSelector("input.button")).Click();

                    Thread.Sleep(3000);
                }
                var str3 = driver.FindElement(By.Id("PaymentAccountIdentifier")).GetAttribute("Value");
                datarow.Newrow("Checkout Name", "Tickle (copy of QA by SB)", attribute,
                    attribute == "Tickle (copy of QA by SB)" ? "PASS" : "FAIL", driver);
                datarow.Newrow("Payment Identifier", "45af07ff-a7dc-4453-89b0-285b85deef2a", str3,
                    str3 == "45af07ff-a7dc-4453-89b0-285b85deef2a" ? "PASS" : "FAIL", driver);
                Thread.Sleep(3000);
                driver.FindElement(By.Id("DefaultCheckoutProcessId")).Click();
                driver.FindElement(By.CssSelector("input.button")).Click();

                driver.FindElement(By.LinkText("…")).Click();

                var str4 = driver.Title;
                datarow.Newrow("Checkout Process Page Title", "Checkout Process : mobank.co.uk/MoShop", str4,
                    str4 == "Checkout Process : mobank.co.uk/MoShop" ? "PASS" : "FAIL",
                    driver);
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Excepion Not Expected", e, "FAIL", driver);
            }
            new ConfigureCheckout().Configure(driver, datarow);
        }
        public void Registration(IWebDriver driver, Datarow datarow)
        {
            var screenshot = new Screenshot();

            var logintitle = driver.Url;
            try
            {
                if (logintitle.Contains("Login") || logintitle.Contains("StepSelectAccountType") ||
                    driver.PageSource.Contains("Login"))
                {
                    //IF the User is a Guest Activate guest Class

                    //Guest guest = new Guest();
                    //guest.guest(driver, datarow);

                    //Calling the Login Class
                    var login = new LoginandRegistrationTps();
                    login.Login_TPS(driver, datarow);
                }

                else if (logintitle.Contains("Checkout"))
                {
                    // calling the checkout class
                    var data = new UserDataTps();
                    data.userdata_TPS(driver, datarow);
                }
                else
                {
                    datarow.Newrow("Checkout Process Not covered in the Framework", "Expected", logintitle, "FAIL",
                                   driver);
                    screenshot.Screenshotfailed(driver);
                }
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Not Expected", e, "FAIL", driver);
                screenshot.Screenshotfailed(driver);
            }
        }
        public void HomepageTabsModro(string homepageTitle, string aboutus, string shipping, string terms,
            Datarow datarow, IWebDriver driver)
        {
            driver.FindElement(By.CssSelector("img")).Click();

            var xpathCount = GetXpathCount(driver, "//body[@id='page-home-index']/div/div[3]/ul/li");
            for (var i = 1; i <= xpathCount; i++)
            {
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0));
                driver.FindElement(By.XPath("//body[@id='page-home-index']/div/div[3]/ul/li[" + i + "]/div/div/a"));
                driver.FindElement(By.XPath("//body[@id='page-home-index']/div/div[3]/ul/li[" + i + "]/div/div/a"))
                      .Click();

                Thread.Sleep(3000);
                var actual = driver.Title;
                if (i > 1)
                {
                    driver.Navigate().Back();
                }
                switch (i)
                {
                    case 1:
                        datarow.Newrow("HomepageTitle", homepageTitle, actual, homepageTitle == actual ? "PASS" : "FAIL",
                            driver);
                        break;

                    case 2:
                        datarow.Newrow("AboutUS", aboutus, actual, aboutus == actual ? "PASS" : "FAIL", driver);
                        break;

                    case 3:
                        datarow.Newrow("Shipping", shipping, actual, shipping == actual ? "PASS" : "FAIL", driver);
                        break;

                    case 4:
                        datarow.Newrow("Terms And Conditions", terms, actual, terms == actual ? "PASS" : "FAIL", driver);
                        break;
                }
            }
        }
コード例 #20
0
        public void Finally(IWebDriver driver, string url, Datarow datarow, string emails)
        {
            new GeneralLibrary();
            try
            {
                //Footer_TPS footer = new Footer_TPS();
                //footer.Footer(driver, , url, datarow);

                //Baskets_TPS basket = new Baskets_TPS();
                //basket.Basket(driver, datarow);

                //links_TPS hom = new links_TPS();
                //hom.Links(datarow,driver, url);

                //UserJourney_TPS userjour = new UserJourney_TPS();
                //userjour.UserJourn(datarow,driver, url);

                //Mopay_TPS Mopay = new Mopay_TPS();
                //Mopay.Mopay(driver, datarow);
            }
            catch (Exception e)
            {
                Console.Write(e);
                var ex = e.ToString();
                var scree = new Screenshot();
                datarow.Newrow("Exception", "Not Expected", ex, "FAIL", driver);
                scree.Screenshotfailed(driver);
            }
            finally
            {
                var split = url.Split(new[] {' ', ',', '.', '/', '\t'});

                foreach (var sr in split)
                {
                    if (split[2] == "m" || split[2] == "www")
                    {
                        if (sr != split[3]) continue;
                        datarow.consolidatedreport(emails);
                        datarow.Excelsave("Mosite-" + sr + "", driver, emails);

                        driver.Quit();
                        break;
                    }
                    if (sr != split[2]) continue;
                    datarow.consolidatedreport(emails);
                    datarow.Excelsave("Mosite-" + sr + "", driver, emails);

                    driver.Quit();
                    break;
                }
            }
        }
 public void Socialmediashare(IWebDriver driver, Datarow datarow)
 {
     driver.FindElement(By.XPath("//div[@id='social-media-sharing']/a[1]/img")).Click();
     driver.FindElement(By.XPath("//div[@id='social-media-sharing']/a[2]/img")).Click();
     driver.FindElement(By.XPath("//div[@id='social-media-sharing']/a[3]/img")).Click();
     var str = driver.WindowHandles.GetEnumerator();
     var parentwindow = driver.CurrentWindowHandle;
     while (str.MoveNext())
     {
         var window = Convert.ToString(str.Current);
         driver.SwitchTo().Window(window);
         var url = driver.Url;
         datarow.Newrow("Social Share URL", "", url, "PASS");
     }
     driver.SwitchTo().Window(parentwindow);
 }
 public void Productsocialshare(IWebDriver driver, Datarow datarow)
 {
     try
     {
         driver.FindElement(By.XPath("//form[@id='customisation-page-update-form']/div[6]/h3")).Click();
         Selectanoption(driver, By.Id("SocialMediaSharingLinks_0__SocialMediaSharingConfigId"), "google plus");
         driver.FindElement(By.CssSelector("input.button")).Click();
         driver.FindElement(By.XPath("//form[@id='customisation-page-update-form']/div[6]/h3")).Click();
         Selectanoption(driver, By.Id("SocialMediaSharingLinks_1__SocialMediaSharingConfigId"), "Facebook");
         driver.FindElement(By.CssSelector("input.button")).Click();
         driver.FindElement(By.XPath("//form[@id='customisation-page-update-form']/div[6]/h3")).Click();
         Selectanoption(driver, By.Id("SocialMediaSharingLinks_2__SocialMediaSharingConfigId"), "Twitter");
         driver.FindElement(By.CssSelector("input.button")).Click();
     }
     catch (Exception ex)
     {
         var e = ex.ToString();
         datarow.Newrow("Exception", "Exception Not Expected", e, "FAIL", driver);
     }
 }
コード例 #23
0
        public void HompageLinks(Datarow datarow, IWebDriver driver)
        {
            var excelData = new GeneralLibrary().GetExcelData(@"C:\\Input Data\Object Repository.xls",
                                                                  "Modrophenia");
            driver.FindElement(By.CssSelector("img")).Click();

            decimal count = driver.FindElements(By.XPath("//html/body/div/div[2]/div/ul/li")).Count;
            var num2 = 0;
            for (var i = 1; i <= count; i++)
            {
                var table = excelData.Tables[0];
                var actual = table.Rows[num2]["HomePageLinks"].ToString();
                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10.0));
                driver.FindElement(By.XPath("//html/body/div/div[2]/div/ul/li[" + i + "]/div/div/a/h2"));
                driver.FindElement(By.XPath("//html/body/div/div[2]/div/ul/li[" + i + "]/div/div/a/h2")).Click();

                var expected = driver.Title;
                datarow.Newrow("Title", expected, actual, expected == actual ? "PASS" : "FAIL", driver);
                num2++;
                driver.Navigate().Back();
            }
        }
コード例 #24
0
        public void Batchtesting(string items, string url, IWebDriver driver, Datarow datarow)
        {
            try
            {
                new BlobStorage();
                // blob.Blob(driver,datarow, url);

                //string[] vesion = verson.Split(',');

                //foreach (string vsion in vesion)
                //{
                //    public const string version = vsion;
                //}

                var selectedvalue = items.Split(',');
                var i = 0;
                foreach (var function in selectedvalue)
                {
                    if (function == "Search")
                    {
                        datarow.Newrow("", "", "Search", "", driver);
                        new Searchsort().Search(driver);
                    }
                    if (function == "Test All Links in Mosite")
                    {
                        datarow.Newrow("", "", "All Links in Mosite - Validations", "", driver);
                        var hom = new LinksTps();
                        hom.Links(datarow, driver, url);
                        i++;
                    }
                    if (function == "Test Footer Links")
                    {
                        datarow.Newrow("", "", "Footer Links", "", driver);
                        var footer = new FooterTps();
                        footer.Footerhome(driver, url, datarow);
                        i++;
                    }
                    if (function == "Test Basket Functionality")
                    {
                        datarow.Newrow("", "", "Basket Functionality", "", driver);
                        var basket = new BasketsTps();
                        basket.Basket(driver, datarow, url);
                        i++;
                    }
                    if (function == "Test Product page - Test Add Product to Basket")
                    {
                        datarow.Newrow("", "", "User Journey", "", driver);
                        var userjour = new UserJourneyTps();
                        userjour.UserJourn(datarow, driver, url);
                        i++;
                    }
                    if (function == "Test Delete From Basket - Test product Unavailable")
                    {
                        datarow.Newrow("", "", "Delete From Basket", "", driver);
                        var delete = new Deletebasketstart();
                        delete.Deletebasstart(driver, datarow);
                        i++;
                    }

                    if (function == "Custom Checkout")
                    {
                        var ckout = new BatchCheckout();
                        ckout.Checkout(driver, url, datarow);
                    }

                    if (function == "Test Registration/Login - CheckOut Pages")
                    {
                        datarow.Newrow("", "", "Registration/Login", "", driver);
                        var login = new LoginRegistration();
                        login.Registration(driver, datarow);
                        i++;
                    }

                    if (function != "Test Mopay") continue;
                    try
                    {
                        datarow.Newrow("", "", "Mopay", "", driver);
                        var pay = new BatchPay();
                        pay.Batchpay(driver, url, datarow);
                    }
                    catch (Exception)
                    {
                        datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver);
                        _screenshot.Screenshotfailed(driver);
                    }

                    i++;
                }
            }
            catch (Exception)
            {
                datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver);
                _screenshot.Screenshotfailed(driver);
            }

            finally
            {
                datarow.Excelsave("Mosite", driver, "*****@*****.**");
                _screenshot.Screenshotfailed(driver);
                driver.Quit();
            }
        }
コード例 #25
0
        public void AddressConfig(IWebDriver driver, Datarow datarow)
        {
            try
            {
                datarow.Newrow("", "", "ADDRESS CONFIGURATION", "", driver);
                driver.FindElement(By.Id("DynamicSourceUrl")).Clear();
                driver.FindElement(By.Id("DynamicSourceUrl"))
                      .SendKeys("https://www.the-tickle-company.co.uk/cgi-bin/os000001.pl?ACTION=Start");
                Selectanoption(driver, By.Id("Method"), "POST");
                //new SelectElement(driver.FindElement(By.Id("Method"))).SelectByText("POST");
                driver.FindElement(By.Id("Url")).Clear();
                driver.FindElement(By.Id("Url")).SendKeys("https://www.the-tickle-company.co.uk/cgi-bin/os000001.pl");
                driver.FindElement(By.Id("LiveScrapeForm_HeaderSelector")).Clear();
                driver.FindElement(By.Id("LiveScrapeForm_HeaderSelector")).SendKeys("#idTableCheckoutSection h2");
                driver.FindElement(By.Id("LiveScrapeForm_SuccessSelector")).Clear();
                driver.FindElement(By.Id("LiveScrapeForm_SuccessSelector")).SendKeys("#GENERALHOWFOUND");
                driver.FindElement(By.Id("LiveScrapeForm_ErrorSelector")).Clear();
                driver.FindElement(By.Id("LiveScrapeForm_ErrorSelector")).SendKeys("#errormessage blockquote");
                driver.FindElement(By.Id("Parameters")).Clear();
                driver.FindElement(By.Id("Parameters"))
                      .SendKeys(
                          "RANDOM=0.346205551018105&SEQUENCE=0&ActCheckoutPhase=INVOICE&ActCheckoutPhase=DELIVER&ActCheckoutPhase=PRELIM&INVOICENAME={{FirstName}}+{{LastName}}&DELIVERNAME={{FirstName}}+{{LastName}}&INVOICEPOSTALCODE={{INVOICEPOSTALCODE}}&DELIVERPOSTALCODE={{INVOICEPOSTALCODE}}&INVOICEADDRESS1={{INVOICEADDRESS1}}&DELIVERADDRESS1={{INVOICEADDRESS1}}&INVOICEADDRESS2={{INVOICEADDRESS2}}&DELIVERADDRESS2={{INVOICEADDRESS2}}&INVOICEADDRESS3={{INVOICEADDRESS3}}&DELIVERADDRESS3={{INVOICEADDRESS3}}&LocationInvoiceCountry={{INVOICECOUNTRY}}&INVOICECOUNTRY={{INVOICECOUNTRY}}&LocationDeliveryCountry={{INVOICECOUNTRY}}&LocationInvoiceRegion=UndefinedRegion&INVOICEADDRESS4={{INVOICEADDRESS4}}&LocationDeliveryRegion=UndefinedRegion&DELIVERADDRESS4={{INVOICEADDRESS4}}&INVOICEPHONE={{INVOICEPHONE}}&DELIVERPHONE={{INVOICEPHONE}}&INVOICEEMAIL={{INVOICEEMAIL}}&DELIVEREMAIL={{INVOICEEMAIL}}&INVOICEEMAIL_CONFIRM={{INVOICEEMAIL}}&DELIVEREMAIL_CONFIRM={{INVOICEEMAIL}}&INVOICEUSERDEFINED={{INVOICEUSERDEFINED}}&ACTION_NEXT.x=87&ACTION_NEXT.y=12");
                driver.FindElement(By.CssSelector("input.button")).Click();

                #region validations

                var attribute = driver.FindElement(By.Id("DynamicSourceUrl")).GetAttribute("Value");
                var actual = driver.FindElement(By.Id("Url")).GetAttribute("Value");
                var str3 = driver.FindElement(By.Id("LiveScrapeForm_HeaderSelector")).GetAttribute("Value");
                var str4 = driver.FindElement(By.Id("LiveScrapeForm_SuccessSelector")).GetAttribute("Value");
                var str5 = driver.FindElement(By.Id("LiveScrapeForm_ErrorSelector")).GetAttribute("Value");
                var str6 = driver.FindElement(By.Id("Parameters")).GetAttribute("Value");

                datarow.Newrow("Dynamic Source URL",
                    "https://www.the-tickle-company.co.uk/cgi-bin/os000001.pl?ACTION=Start", attribute,
                    attribute == "https://www.the-tickle-company.co.uk/cgi-bin/os000001.pl?ACTION=Start"
                        ? "PASS"
                        : "FAIL", driver);
                datarow.Newrow("URL", "https://www.the-tickle-company.co.uk/cgi-bin/os000001.pl", actual,
                    actual == "https://www.the-tickle-company.co.uk/cgi-bin/os000001.pl" ? "PASS" : "FAIL",
                    driver);
                datarow.Newrow("Header Selector", "#idTableCheckoutSection h2", str3,
                    str3 == "#idTableCheckoutSection h2" ? "PASS" : "FAIL", driver);
                datarow.Newrow("Success Selector", "#GENERALHOWFOUND", str4,
                    str4 == "#GENERALHOWFOUND" ? "PASS" : "FAIL", driver);
                datarow.Newrow("Error Selector", "#errormessage blockquote", str5,
                    str5 == "#errormessage blockquote" ? "PASS" : "FAIL", driver);
                datarow.Newrow("Parameters",
                    "RANDOM=0.346205551018105&SEQUENCE=0&ActCheckoutPhase=INVOICE&ActCheckoutPhase=DELIVER&ActCheckoutPhase=PRELIM&INVOICENAME={{FirstName}}+{{LastName}}&DELIVERNAME={{FirstName}}+{{LastName}}&INVOICEPOSTALCODE={{INVOICEPOSTALCODE}}&DELIVERPOSTALCODE={{INVOICEPOSTALCODE}}&INVOICEADDRESS1={{INVOICEADDRESS1}}&DELIVERADDRESS1={{INVOICEADDRESS1}}&INVOICEADDRESS2={{INVOICEADDRESS2}}&DELIVERADDRESS2={{INVOICEADDRESS2}}&INVOICEADDRESS3={{INVOICEADDRESS3}}&DELIVERADDRESS3={{INVOICEADDRESS3}}&LocationInvoiceCountry={{INVOICECOUNTRY}}&INVOICECOUNTRY={{INVOICECOUNTRY}}&LocationDeliveryCountry={{INVOICECOUNTRY}}&LocationInvoiceRegion=UndefinedRegion&INVOICEADDRESS4={{INVOICEADDRESS4}}&LocationDeliveryRegion=UndefinedRegion&DELIVERADDRESS4={{INVOICEADDRESS4}}&INVOICEPHONE={{INVOICEPHONE}}&DELIVERPHONE={{INVOICEPHONE}}&INVOICEEMAIL={{INVOICEEMAIL}}&DELIVEREMAIL={{INVOICEEMAIL}}&INVOICEEMAIL_CONFIRM={{INVOICEEMAIL}}&DELIVEREMAIL_CONFIRM={{INVOICEEMAIL}}&INVOICEUSERDEFINED={{INVOICEUSERDEFINED}}&ACTION_NEXT.x=87&ACTION_NEXT.y=12",
                    str6, str6 ==
                          "RANDOM=0.346205551018105&SEQUENCE=0&ActCheckoutPhase=INVOICE&ActCheckoutPhase=DELIVER&ActCheckoutPhase=PRELIM&INVOICENAME={{FirstName}}+{{LastName}}&DELIVERNAME={{FirstName}}+{{LastName}}&INVOICEPOSTALCODE={{INVOICEPOSTALCODE}}&DELIVERPOSTALCODE={{INVOICEPOSTALCODE}}&INVOICEADDRESS1={{INVOICEADDRESS1}}&DELIVERADDRESS1={{INVOICEADDRESS1}}&INVOICEADDRESS2={{INVOICEADDRESS2}}&DELIVERADDRESS2={{INVOICEADDRESS2}}&INVOICEADDRESS3={{INVOICEADDRESS3}}&DELIVERADDRESS3={{INVOICEADDRESS3}}&LocationInvoiceCountry={{INVOICECOUNTRY}}&INVOICECOUNTRY={{INVOICECOUNTRY}}&LocationDeliveryCountry={{INVOICECOUNTRY}}&LocationInvoiceRegion=UndefinedRegion&INVOICEADDRESS4={{INVOICEADDRESS4}}&LocationDeliveryRegion=UndefinedRegion&DELIVERADDRESS4={{INVOICEADDRESS4}}&INVOICEPHONE={{INVOICEPHONE}}&DELIVERPHONE={{INVOICEPHONE}}&INVOICEEMAIL={{INVOICEEMAIL}}&DELIVEREMAIL={{INVOICEEMAIL}}&INVOICEEMAIL_CONFIRM={{INVOICEEMAIL}}&DELIVEREMAIL_CONFIRM={{INVOICEEMAIL}}&INVOICEUSERDEFINED={{INVOICEUSERDEFINED}}&ACTION_NEXT.x=87&ACTION_NEXT.y=12"
                        ? "PASS"
                        : "FAIL", driver);

                #endregion

                new AddressElements().Elements(driver, datarow);

                #region Validations

                var str13 = driver.FindElement(By.Id("LiveScrapeForm_Elements_0__Label")).GetAttribute("Value");
                datarow.Newrow("First Name", "First Name: *", str13, str13 == "First Name: *" ? "PASS" : "FAIL", driver);
                var str14 = Option(driver, By.Id("LiveScrapeForm_Elements_0__PropertyPath"), 30);
                datarow.Newrow("FirstName Property", "FirstName", str14, str14 == "FirstName" ? "PASS" : "FAIL", driver);
                var str15 = driver.FindElement(By.Id("LiveScrapeForm_Elements_1__Label")).GetAttribute("Value");
                datarow.Newrow("LastName", "Last Name: *", str15, str15 == "Last Name: *" ? "PASS" : "FAIL", driver);
                var str16 = Option(driver, By.Id("LiveScrapeForm_Elements_1__PropertyPath"), 30);
                datarow.Newrow("Last Name Property", "LastName", str16, str16 == "LastName" ? "PASS" : "FAIL", driver);
                var str17 = driver.FindElement(By.Id("LiveScrapeForm_Elements_2__Label")).GetAttribute("Value");
                datarow.Newrow("PostCode", "Post Code: *", str17, str17 == "Post Code: *" ? "PASS" : "FAIL", driver);
                var str18 = GetValue(driver, By.Id("LiveScrapeForm_Elements_2__LabelSelector"), 30);
                datarow.Newrow("PostCode Equation", ".actrequired:eq(1)", str18,
                    str18 == ".actrequired:eq(1)" ? "PASS" : "FAIL", driver);
                var str19 = Option(driver, By.Id("LiveScrapeForm_Elements_2__PropertyPath"), 30);
                datarow.Newrow("Postcode Property", "PostCode", str19, str19 == "PostCode" ? "PASS" : "FAIL", driver);
                var str20 =
                    driver.FindElement(By.Id("LiveScrapeForm_Elements_3__LabelSelector")).GetAttribute("Value");
                datarow.Newrow("Address Equation", ".actrequired:eq(2)", str20,
                    str20 == ".actrequired:eq(2)" ? "PASS" : "FAIL", driver);
                var str21 = driver.FindElement(By.Id("LiveScrapeForm_Elements_3__Label")).GetAttribute("Value");
                datarow.Newrow("Address", "Address Line 1: *", str21, str21 == "Address Line 1: *" ? "PASS" : "FAIL",
                    driver);
                var text = GetValue(driver, By.Id("id=LiveScrapeForm_Elements_3__PropertyPath"), 30);
                if (text == "Address1")
                {
                    datarow.Newrow("Address Property", "Address1", text, "PASS", driver);
                }
                else
                {
                    datarow.Newrow("Address Property", "Address1", text, "PASS", driver);
                }
                var str23 =
                    driver.FindElement(By.Id("LiveScrapeForm_Elements_4__LabelSelector")).GetAttribute("Value");
                datarow.Newrow("Address Equation2", "#idBothAddressesTable tr:eq(5) td:eq(0)", str23,
                    str23 == "#idBothAddressesTable tr:eq(5) td:eq(0)" ? "PASS" : "FAIL", driver);
                var str24 = driver.FindElement(By.Id("LiveScrapeForm_Elements_4__Label")).GetAttribute("Value");
                datarow.Newrow("Address2", "Address Line 2:", str24, str24 == "Address Line 2:" ? "PASS" : "FAIL",
                    driver);
                var str25 = Option(driver, By.Id("LiveScrapeForm_Elements_4__PropertyPath"), 30);
                datarow.Newrow("Address2Property", "Address2", str25, str25 == "Address2" ? "PASS" : "FAIL", driver);
                var str26 =
                    driver.FindElement(By.Id("LiveScrapeForm_Elements_5__LabelSelector")).GetAttribute("Value");
                datarow.Newrow("City Equation", ".actrequired:eq(3)", str26,
                    str26 == ".actrequired:eq(3)" ? "PASS" : "FAIL", driver);
                var str27 = driver.FindElement(By.Id("LiveScrapeForm_Elements_5__Label")).GetAttribute("Value");
                datarow.Newrow("Billing City", "City/Town: *", str27, str27 == "City/Town: *" ? "PASS" : "FAIL", driver);
                var str28 = Option(driver, By.Id("LiveScrapeForm_Elements_5__PropertyPath"), 30);
                datarow.Newrow("Billing City Property", "BillingCity", str28, str28 == "BillingCity" ? "PASS" : "FAIL",
                    driver);
                var str29 =
                    driver.FindElement(By.Id("LiveScrapeForm_Elements_6__LabelSelector")).GetAttribute("Value");
                datarow.Newrow("Country Eqaution", "#idBothAddressesTable tr:eq(7) td:eq(0)", str29,
                    str29 == "#idBothAddressesTable tr:eq(7) td:eq(0)" ? "PASS" : "FAIL", driver);
                var str30 = driver.FindElement(By.Id("LiveScrapeForm_Elements_6__Label")).GetAttribute("Value");
                datarow.Newrow("Country", "Country: *", str30, str30 == "Country: *" ? "PASS" : "FAIL", driver);
                var str31 =
                    driver.FindElement(By.Id("LiveScrapeForm_Elements_6__KeysValuesSelector")).GetAttribute("Value");
                datarow.Newrow("Country Option", "#lstInvoiceCountry option", str31,
                    str31 == "#lstInvoiceCountry option" ? "PASS" : "FAIL", driver);
                var str32 = Option(driver, By.Id("LiveScrapeForm_Elements_6__PropertyPath"), 30);
                datarow.Newrow("Country Property", "Country", str32, str32 == "Country" ? "PASS" : "FAIL", driver);
                datarow.Newrow("County Equation", "#idBothAddressesTable tr:eq(8) td:eq(0)", str29,
                    driver.FindElement(By.Id("LiveScrapeForm_Elements_7__LabelSelector")).GetAttribute("Value") ==
                    "#idBothAddressesTable tr:eq(8) td:eq(0)"
                        ? "PASS"
                        : "FAIL", driver);
                var str34 = driver.FindElement(By.Id("LiveScrapeForm_Elements_7__Label")).GetAttribute("Value");
                datarow.Newrow("County", "County:", str34, str34 == "County:" ? "PASS" : "FAIL", driver);
                var str35 = GetValue(driver, By.Id("LiveScrapeForm_Elements_7__PropertyPath"), 30);
                if (str35 == "County")
                {
                    datarow.Newrow("County Property", "County", str35, "PASS", driver);
                }
                else
                {
                    datarow.Newrow("County Property", "County", str35, "PASS", driver);
                }
                var str36 = GetValue(driver, By.Id("LiveScrapeForm_Elements_8__LabelSelector"), 30);
                datarow.Newrow("Phone Equation", "#idBothAddressesTable tr:eq(9) td:eq(0)", str36,
                    str36 == "#idBothAddressesTable tr:eq(9) td:eq(0)" ? "PASS" : "FAIL", driver);
                var str37 = driver.FindElement(By.Id("LiveScrapeForm_Elements_8__Label")).GetAttribute("Value");
                datarow.Newrow("Phone Number", "Phone Number:", str37, str37 == "Phone Number:" ? "PASS" : "FAIL",
                    driver);
                var str38 = Option(driver, By.Id("LiveScrapeForm_Elements_8__PropertyPath"), 30);
                datarow.Newrow("Phone Property", "Phone", str38, str38 == "Phone" ? "PASS" : "FAIL", driver);
                var str39 = GetValue(driver, By.Id("LiveScrapeForm_Elements_9__LabelSelector"), 30);
                datarow.Newrow("Email Equation", "#idINVOICEEMAILlabel", str39,
                    str39 == "#idINVOICEEMAILlabel" ? "PASS" : "FAIL", driver);
                var str40 = GetValue(driver, By.Id("LiveScrapeForm_Elements_9__Label"), 30);
                datarow.Newrow("Email", "Email Address: *", str40, str40 == "Email Address: *" ? "PASS" : "FAIL", driver);
                var str41 = Option(driver, By.Id("LiveScrapeForm_Elements_9__PropertyPath"), 30);
                datarow.Newrow("Email Property", "Email", str41, str41 == "Email" ? "PASS" : "FAIL", driver);

                #endregion
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Exception not expectd", e, "FAIL");
            }

            new DeliveryTab().Delivery(driver, datarow);
        }
コード例 #26
0
        public void CreateScrape(IWebDriver driver, Datarow datarow)
        {
            try
            {
                driver.FindElement(By.LinkText("MoShop")).Click();

                var actual = driver.Title;
                datarow.Newrow("HomePage Title", "mobank.co.uk/MoShop", actual,
                    actual == "mobank.co.uk/MoShop" ? "PASS" : "FAIL", driver);
                driver.FindElement(By.LinkText("Scrapes")).Click();

                var str2 = driver.Title;
                datarow.Newrow("Scrape Page Title", "Scrapes :  mobank.co.uk/MoShop", str2,
                    str2 == "Scrapes : mobank.co.uk/MoShop" ? "PASS" : "FAIL", driver);

                driver.FindElement(By.LinkText("Create")).Click();
                driver.FindElement(By.Id("Name")).Clear();
                driver.FindElement(By.Id("Name")).SendKeys("TestShop-Scrape");
                driver.FindElement(By.CssSelector("p.submit.submitInline > input.button")).Click();

                Selectanoption(driver, By.Id("Profiles_0__Shop_Value"), "testshop");
                //new SelectElement(driver.FindElement(By.Id("Profiles_0__Shop_Value"))).SelectByText("testshop");
                driver.FindElement(By.CssSelector("input.button")).Click();

                var str3 = driver.Title;
                datarow.Newrow("Scrape Title", "Scrape :  mobank.co.uk/MoShop", str3,
                    str3 == "Scrape : mobank.co.uk/MoShop" ? "PASS" : "FAIL", driver);
                driver.FindElement(By.Id("Profiles_0__RootUrl")).Clear();
                driver.FindElement(By.Id("Profiles_0__RootUrl")).SendKeys("http://www.the-tickle-company.co.uk/");
                Selectanoption(driver, By.Id("Profiles_0__Encoding"), "iso-8859-1 - Western European (ISO)");
                //new SelectElement(driver.FindElement(By.Id("Profiles_0__Encoding"))).SelectByText("iso-8859-1 - Western European (ISO)");
                driver.FindElement(By.CssSelector("input.button")).Click();

                var attribute = driver.FindElement(By.Id("Profiles_0__RootUrl")).GetAttribute("Value");
                driver.FindElement(By.Id("Profiles_0__Encoding")).GetAttribute("Value");
                datarow.Newrow("Root URL", "http://www.the-tickle-company.co.uk/", attribute,
                    attribute == "http://www.the-tickle-company.co.uk/" ? "PASS" : "FAIL", driver);
                driver.FindElement(By.Id("Pages_0__Name")).Clear();
                driver.FindElement(By.Id("Pages_0__Name")).SendKeys("Categories");
                Selectanoption(driver, By.Id("Pages_0__ObjectTypeName"), "Category");
                //new SelectElement(driver.FindElement(By.Id("Pages_0__ObjectTypeName"))).SelectByText("Category");
                driver.FindElement(By.CssSelector("input.button")).Click();

                var str6 = driver.FindElement(By.Id("Pages_0__Name")).GetAttribute("Value");
                driver.FindElement(By.Id("Pages_0__ObjectTypeName")).GetAttribute("option value");
                datarow.Newrow("Page Name", "Categories", str6, str6 == "Categories" ? "PASS" : "FAIL", driver);
                driver.FindElement(By.XPath("(//a[contains(text(),'…')])[2]")).Click();

                if (driver.PageSource.Contains("Server Error in '/' Application."))
                {
                    driver.Navigate().Back();

                    driver.FindElement(By.CssSelector("input.button")).Click();

                    driver.FindElement(By.XPath("(//a[contains(text(),'…')])[2]")).Click();
                }
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "", e, "FAIL");
            }
            new CategoryScrape().ScarpeCategory(driver, datarow);
        }
コード例 #27
0
        public void Scrapeandfeedrunning(IWebDriver driver, Datarow datarow)
        {
            #region  Running

            for (var j = 1;;)
            {
                if (IsElementPresent(driver, By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[7]"), 30))
                {
                    for (var i = 0;; i++)
                    {
                        try
                        {
                            var comp =
                                driver.FindElement(By.XPath("//div[@id='Grid']/div[2]/table/tbody/tr/td[7]")).Text;
                            if (comp.Contains("100%"))
                            {
                                datarow.Newrow("Scarpe status", "", comp, "PASS", driver);
                                break;
                            }
                            datarow.Newrow("Scarpe/Datafeed status", "", comp, "PASS", driver);
                            Thread.Sleep(5000);
                            driver.Navigate().Refresh();
                        }
                        catch (Exception)
                        {
                            datarow.Newrow("Scarpe/DataFeed Status", "100%", "100%", "PASS", driver);
                            break;
                        }
                    }
                    break;
                }
                Thread.Sleep(5000);
                driver.Navigate().Refresh();

                j++;
                if (j != 10) continue;
                datarow.Newrow("Scarpe/Datafeed Start", "Scrape/Datafeed should start",
                    "Scrape/Datafeed didnt start after 60 sec", "FAIL", driver);
                break;
            }

            #endregion

            driver.FindElement(By.LinkText("Completed")).Click();

            var completed = driver.FindElement(By.CssSelector("td.markedCell")).Text;
            if (completed.Contains("100%"))
            {
                datarow.Newrow("Scrape/DataFeed Job Completed", "", completed, "PASS", driver);
            }
        }
コード例 #28
0
        public void Schedule(IWebDriver driver, Datarow datarow)
        {
            try
            {
                int num;
                string str4;
                string str5;
                string str6;
                string str7;
                string str8;
                string str9;
                string str10;
                string str11;
                string str12;
                string str13;
                driver.FindElement(By.LinkText("Shops")).Click();
                driver.FindElement(By.LinkText("testshop")).Click();

                driver.FindElement(By.LinkText("Scheduler")).Click();

                datarow.Newrow("", "", "SCHEDULER", "", driver);
                if (IsElementPresent(driver, By.CssSelector("h3.collapsible.collapsed"), 30))
                {
                    driver.FindElement(By.CssSelector("h3.collapsible.collapsed")).Click();
                }
                var str = GetValue(driver, By.Id("Jobs_0__JobType"), 30);
                if (str == null)
                {
                    Selectanoption(driver, By.Id("Jobs_0__JobType"), "Scrape");
                    //new SelectElement(driver.FindElement(By.Id("Jobs_0__JobType"))).SelectByText("Scrape");
                    driver.FindElement(By.CssSelector("input.button")).Click();

                    var attribute = driver.FindElement(By.Id("Jobs_0__JobType")).GetAttribute("Value");
                    datarow.Newrow("Job Type", "Scrape", attribute, attribute == "Scrape" ? "PASS" : "FAIL", driver);
                    driver.FindElement(By.Id("Jobs_0__Active")).Click();
                    driver.FindElement(By.Id("Jobs_0__StartOn")).Clear();
                    driver.FindElement(By.Id("Jobs_0__StartOn")).SendKeys("7/31/2012 11:19:00 AM");
                    driver.FindElement(By.Id("Jobs_0__EndOn")).Clear();
                    driver.FindElement(By.Id("Jobs_0__EndOn")).SendKeys("7/31/2013 11:19:00 AM");
                    driver.FindElement(By.Id("Jobs_0__RepeatInterval_Days")).Clear();
                    driver.FindElement(By.Id("Jobs_0__RepeatInterval_Days")).SendKeys("1");
                    driver.FindElement(By.Id("Jobs_0__RepeatInterval_Hours")).Clear();
                    driver.FindElement(By.Id("Jobs_0__RepeatInterval_Hours")).SendKeys("0");
                    driver.FindElement(By.CssSelector("input.button")).Click();

                    Selectanoption(driver, By.Id("Jobs_1__JobType"), "Data Feed");
                    //new SelectElement(driver.FindElement(By.Id("Jobs_1__JobType"))).SelectByText("Data Feed");
                    driver.FindElement(By.CssSelector("input.button")).Click();

                    Thread.Sleep(0x1388);
                    var str3 = GetValue(driver, By.Id("Jobs_1__Active"), 30);
                    num = 0;
                    if (str3 == "true")
                    {
                        num = 1;
                    }
                    str4 = driver.FindElement(By.Id("Jobs_" + num + "__Active")).GetAttribute("Value");
                    str5 = driver.FindElement(By.Id("Jobs_" + num + "__StartOn")).GetAttribute("Value");
                    str6 = driver.FindElement(By.Id("Jobs_" + num + "__EndOn")).GetAttribute("Value");
                    str7 = driver.FindElement(By.Id("Jobs_" + num + "__RepeatInterval_Days")).GetAttribute("Value");
                    str8 = driver.FindElement(By.Id("Jobs_" + num + "__RepeatInterval_Hours")).GetAttribute("Value");

                    #region validation

                    if (str4 == "true")
                    {
                        datarow.Newrow("Scheduler Scrape Activation", "Scrape Activated", str4, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Scheduler Scrape Activation", "Scrape Not Activated", str4, "FAIL", driver);
                    }
                    datarow.Newrow("Schduler Start Time", "31 Jul 2012 11:19", str5,
                        str5 == "31 Jul 2012 11:19" ? "PASS" : "FAIL", driver);
                    if (str6 == "31 Jul 2013 11:19")
                    {
                        datarow.Newrow("Schduler End Time", "31 Jul 2013 11:19", str6, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Schduler End Time", "31 Jul 2013 11:19", str6, "PASS", driver);
                    }
                    datarow.Newrow("Repeat interval Days", "1", str7, str7 == "1" ? "PASS" : "FAIL", driver);
                    datarow.Newrow("Repeat interval Hours", "0", str8, str8 == "0" ? "PASS" : "FAIL", driver);

                    #endregion

                    if (str3 == "false")
                    {
                        driver.FindElement(By.Id("Jobs_1__Active")).Click();
                        driver.FindElement(By.Id("Jobs_1__Url")).Clear();
                        driver.FindElement(By.Id("Jobs_1__Url"))
                              .SendKeys("https://dl.dropbox.com/u/93702113/test-catalogue-small.xml");
                        driver.FindElement(By.Id("Jobs_1__StartOn")).Clear();
                        driver.FindElement(By.Id("Jobs_1__StartOn")).SendKeys("7/31/2012 11:20:00 AM");
                        driver.FindElement(By.Id("Jobs_1__EndOn")).Clear();
                        driver.FindElement(By.Id("Jobs_1__EndOn")).SendKeys("7/31/2013 11:20:00 AM");
                        driver.FindElement(By.Id("Jobs_1__RepeatInterval_Days")).Clear();
                        driver.FindElement(By.Id("Jobs_1__RepeatInterval_Days")).SendKeys("1");
                        driver.FindElement(By.Id("Jobs_1__RepeatInterval_Hours")).Clear();
                        driver.FindElement(By.Id("Jobs_1__RepeatInterval_Hours")).SendKeys("1");
                        driver.FindElement(By.CssSelector("input.button")).Click();
                    }
                    else
                    {
                        driver.FindElement(By.Id("Jobs_0__Active")).Click();
                        driver.FindElement(By.Id("Jobs_0__Url")).Clear();
                        driver.FindElement(By.Id("Jobs_0__Url"))
                              .SendKeys("https://dl.dropbox.com/u/93702113/test-catalogue-small.xml");
                        driver.FindElement(By.Id("Jobs_0__StartOn")).Clear();
                        driver.FindElement(By.Id("Jobs_0__StartOn")).SendKeys("7/31/2012 11:20:00 AM");
                        driver.FindElement(By.Id("Jobs_0__EndOn")).Clear();
                        driver.FindElement(By.Id("Jobs_0__EndOn")).SendKeys("7/31/2013 11:20:00 AM");
                        driver.FindElement(By.Id("Jobs_0__RepeatInterval_Days")).Clear();
                        driver.FindElement(By.Id("Jobs_0__RepeatInterval_Days")).SendKeys("1");
                        driver.FindElement(By.Id("Jobs_0__RepeatInterval_Hours")).Clear();
                        driver.FindElement(By.Id("Jobs_0__RepeatInterval_Hours")).SendKeys("1");
                        driver.FindElement(By.CssSelector("input.button")).Click();
                    }
                    var num2 = 0;
                    if (str3 == "false")
                    {
                        num2 = 1;
                    }
                    str9 = driver.FindElement(By.Id("Jobs_" + num2 + "__Active")).GetAttribute("Value");
                    str10 = driver.FindElement(By.Id("Jobs_" + num2 + "__StartOn")).GetAttribute("Value");
                    str11 = driver.FindElement(By.Id("Jobs_" + num2 + "__EndOn")).GetAttribute("Value");
                    str12 = driver.FindElement(By.Id("Jobs_" + num2 + "__RepeatInterval_Days")).GetAttribute("Value");
                    str13 = driver.FindElement(By.Id("Jobs_" + num2 + "__RepeatInterval_Hours")).GetAttribute("Value");

                    #region validations

                    if (str9 == "true")
                    {
                        datarow.Newrow("Scheduler DataFeed Activation", "DataFeed Activated", str9, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Scheduler DataFeed Activation", "DataFeed Not Activated", str9, "FAIL", driver);
                    }
                    datarow.Newrow("Scheduler Start Time", "31 Jul 2012 11:20", str10,
                        str10 == "31 Jul 2012 11:20" ? "PASS" : "FAIL", driver);
                    if (str11 == "31 Jul 2012 11:19")
                    {
                        datarow.Newrow("Scheduler End Time", "31 Jul 2012 11:20", str11, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Scheduler End Time", "31 Jul 2012 11:20", str11, "PASS", driver);
                    }
                    datarow.Newrow("Repeat interval Days", "1", str12, str12 == "1" ? "PASS" : "FAIL", driver);
                    datarow.Newrow("Repeat interval Hours", "1", str13, str13 == "1" ? "PASS" : "FAIL", driver);

                    #endregion
                }
                else
                {
                    #region Validations

                    num = 0;
                    str4 = driver.FindElement(By.Id("Jobs_" + num + "__Active")).GetAttribute("Value");
                    str5 = driver.FindElement(By.Id("Jobs_" + num + "__StartOn")).GetAttribute("Value");
                    str6 = driver.FindElement(By.Id("Jobs_" + num + "__EndOn")).GetAttribute("Value");
                    str7 = driver.FindElement(By.Id("Jobs_" + num + "__RepeatInterval_Days")).GetAttribute("Value");
                    str8 = driver.FindElement(By.Id("Jobs_" + num + "__RepeatInterval_Hours")).GetAttribute("Value");

                    if (str4 == "true")
                    {
                        datarow.Newrow("Scheduler Scrape Activation", "Scrape Activated", str4, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Scheduler Scrape Activation", "Scrape Not Activated", str4, "FAIL", driver);
                    }
                    datarow.Newrow("Schduler Start Time", "31 Jul 2012 11:19", str5,
                        str5 == "31 Jul 2012 11:19" ? "PASS" : "FAIL", driver);
                    if (str6 == "31 Jul 2012 11:19")
                    {
                        datarow.Newrow("Schduler End Time", "31 Jul 2012 11:19", str6, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Schduler End Time", "31 Jul 2012 11:19", str6, "PASS", driver);
                    }
                    datarow.Newrow("Repeat interval Days", "1", str7, str7 == "1" ? "PASS" : "FAIL", driver);
                    datarow.Newrow("Repeat interval Hours", "1", str8, str8 == "1" ? "PASS" : "FAIL", driver);

                    const int num3 = 1;
                    str9 = driver.FindElement(By.Id("Jobs_" + num3 + "__Active")).GetAttribute("Value");
                    str10 = driver.FindElement(By.Id("Jobs_" + num3 + "__StartOn")).GetAttribute("Value");
                    str11 = driver.FindElement(By.Id("Jobs_" + num3 + "__EndOn")).GetAttribute("Value");
                    str12 = driver.FindElement(By.Id("Jobs_" + num3 + "__RepeatInterval_Days")).GetAttribute("Value");
                    str13 = driver.FindElement(By.Id("Jobs_" + num3 + "__RepeatInterval_Hours")).GetAttribute("Value");
                    if (str9 == "true")
                    {
                        datarow.Newrow("Scheduler Scrape Activation", "Scrape Activated", str4, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Scheduler Scrape Activation", "Scrape Not Activated", str4, "FAIL", driver);
                    }
                    datarow.Newrow("Schduler Start Time", "31 Jul 2012 11:19", str5,
                        str10 == "31 Jul 2012 11:19" ? "PASS" : "FAIL", driver);
                    if (str11 == "31 Jul 2012 11:19")
                    {
                        datarow.Newrow("Schduler End Time", "31 Jul 2012 11:19", str6, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Schduler End Time", "31 Jul 2012 11:19", str6, "PASS", driver);
                    }
                    datarow.Newrow("Repeat interval Days", "1", str7, str12 == "1" ? "PASS" : "FAIL", driver);
                    datarow.Newrow("Repeat interval Hours", "1", str8, str13 == "24" ? "PASS" : "FAIL", driver);

                    #endregion
                }
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Excepion Not Expected", e, "FAIL", driver);
            }
            new Checkout.Checkout().CheckouT(driver, datarow);
        }
コード例 #29
0
        public void AllLink(IWebDriver driver, Datarow datarow)
        {
            var url = driver.PageSource;
            string categorylink;
            string cat;
            string products;
            string productlink;
            if (url.Contains("user-scalable=yes"))
            {
                categorylink = CollectionMapV2.Categorylink;
                cat = CollectionMapV2.Cat;
                products = CollectionMapV2.Products;
                productlink = CollectionMapV2.Productlink;
            }
            else
            {
                categorylink = CollectionMapV1.Categorylink;
                cat = CollectionMapV1.Cat;
                products = CollectionMapV1.Products;
                productlink = CollectionMapV1.Productlink;
            }
            // This method counts the categories,sub-categories, product pages and validate every product link
            var screenshot = new Screenshot();

            try
            {
                var image = new Imagevalidation();
                //Home Page Image validation

                image.Homepageimage(driver, datarow);
                //Counting the number of Categories
                decimal linkcount = driver.FindElements(By.XPath(categorylink)).Count;
                if (linkcount == 0)
                {
                    datarow.Newrow("Category Validation in Home Page", "Atleast One Category/product is Expected",
                                   "No Categories/Products are Identified", "FAIL", driver);
                }
                var j = 0;
                var s = 1;

                //Running the loop through the category links
                for (var i = 1; i <= linkcount; i++)
                {
                    try
                    {
                        driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                        driver.FindElement(By.XPath("" + categorylink + "[" + i + "]" + cat + ""));
                        driver.FindElement(By.XPath("" + categorylink + "[" + i + "]" + cat + "")).Click();
                    }
                    catch (Exception ex)
                    {
                        var e = ex.ToString();
                        datarow.Newrow("Category Element Exception", "Exception Not Expected", e, "FAIL", driver);
                        screenshot.Screenshotfailed(driver);
                    }
                    var categorycount = GetXpathCount(driver, categorylink);
                    if (categorycount == 0)
                    {
                        datarow.Newrow("Category Validation in  Page", "Atleast One Category/product",
                                       "No Categories/Products", "FAIL", driver);
                        screenshot.Screenshotfailed(driver);
                    }
                    //Running the loop through sub category pages.
                    for (var k = 1; ; k++)
                    {
                        try
                        {
                            if (IsElementPresent(driver, By.XPath("" + categorylink + "[" + k + "]" + cat + "")))
                            {
                                //*[@id="productList"]/article[1]/a/div[1]/img
                                // Category Image validation
                                image.categoryimage(driver, datarow);
                                driver.FindElement(By.XPath("" + categorylink + "[" + k + "]" + cat + "")).Click();

                                var titlecategory = driver.Title;

                                // Sub-Category Image validation
                                image.subcategoryimage(driver, datarow);

                                try
                                {
                                    if (IsElementPresent(driver,
                                                         By.XPath("" + products + "[" + 1 + "]" + productlink + "")))
                                    {
                                        datarow.Newrow("Product Title", "", titlecategory, "PASS", driver);
                                        //This is to test the product page
                                        var productcount = GetXpathCount(driver, products);
                                        for (var p = 1; p <= productcount; p++)
                                        {
                                            driver.FindElement(By.XPath("" + products + "[" + p + "]" + productlink + ""))
                                                  .Click();

                                            var page = new Productpage();
                                            page.ProductPage(driver, datarow);

                                            driver.Navigate().Back();
                                        }
                                    }
                                    else
                                    {
                                        datarow.Newrow("Category Title", "", titlecategory, "PASS", driver);
                                        k = 0;
                                    }
                                }
                                catch (Exception exc)
                                {
                                    var e = exc.ToString();
                                    datarow.Newrow("Exception For Product Details", "Exception Not Expected", e, "FAIL",
                                                   driver);
                                    screenshot.Screenshotfailed(driver);
                                }
                            }

                            k = s;
                            driver.Navigate().Back();

                            s++;
                            var url2 = driver.Url;
                            if (url2.Contains("category"))
                            {
                                datarow.Newrow("Category URL", "", url2, "PASS", driver);
                            }
                            else
                            {
                                s = 1;
                                break;
                            }
                        }
                        catch (Exception ex)
                        {
                            var e = ex.ToString();
                            datarow.Newrow("Category/Product Link Exception", "Exception Not Expected", e, "FAIL",
                                           driver);
                            screenshot.Screenshotfailed(driver);
                        }
                    }

                    j++;

                    //driver.Navigate().Back();
                    //
                }
            }
            catch (Exception)
            {
                datarow.Newrow("Exception", "", "Exception Not Expected", "FAIL", driver);
                screenshot.Screenshotfailed(driver);
            }
        }
コード例 #30
0
        public void ProductPage(IWebDriver driver, Datarow datarow)
        {
            var url = driver.PageSource;

            string productprice;
            string productVarinat;
            string producttitle;
            string detaiL;

            new Imagevalidation();
            new Screenshot();

            if (url.Contains("user-scalable=yes"))
            {
                productprice = CollectionMapV2.ProductPrice;
                producttitle = CollectionMapV2.Producttitle;
                detaiL = CollectionMapV2.Detail;
                productVarinat = CollectionMapV2.ProductVariant;
            }
            else
            {
                productprice = CollectionMapV1.ProductPrice;
                producttitle = CollectionMapV1.Producttitle;
                detaiL = CollectionMapV1.Detail;
                productVarinat = CollectionMapV1.ProductVariant;
            }

            var price = driver.FindElement(By.XPath(productprice)).Text;
            datarow.Newrow("Product Price", "", price, "PASS", driver);

            //Deleted Click and  Expand Details Tab

            var detail = driver.FindElement(By.XPath(detaiL)).Text;
            datarow.Newrow("Product Detail", "", detail, "PASS", driver);

            var titles = driver.FindElement(By.XPath(producttitle)).Text;
            datarow.Newrow("Product Title", "", titles, "PASS", driver);

            if (IsElementPresent(driver, By.Id("" + productVarinat + ""), 30))
            {
                try
                {
                    decimal couent =
                        driver.FindElements(
                            By.XPath(
                                "//html/body/div/div[2]/div/div[4]/form/ul/li[2]/fieldset/div[2]/div/label/span"))
                            .Count;

                    if (couent != 1)
                    {
                        var element = driver.FindElement(By.Id("" + productVarinat + ""));
                        IList<IWebElement> AllDropDownList = element.FindElements(By.XPath("option"));

                        string values = null;
                        foreach (var value in AllDropDownList.Where(value => value.Text != "Please Select"))
                        {
                            values = values + "\r\n" + value;
                            new SelectElement(driver.FindElement(By.Id(productVarinat))).SelectByText(value.Text);
                        }
                        datarow.Newrow("Variants", "", values, "PASS", driver);
                    }

                    else
                    {
                        var varinats = driver.FindElement(By.Id("" + productVarinat + "")).GetAttribute("Value");
                        datarow.Newrow("Variants", "", varinats, "PASS", driver);
                    }
                }
                catch (Exception ex)
                {
                    var e = ex.ToString();

                    datarow.Newrow("Exception Not Expected", "Exception Not Expected", e, "FAIL");
                }
            }

            else if (IsElementPresent(driver, By.Id("" + productVarinat + "_0"), 30))
            {
                string values = null;
                for (var q = 1;; q++)
                {
                    if (IsElementPresent(driver, By.Id("" + productVarinat + "" + q + ""), 30))
                    {
                        var varinats = driver.FindElement(By.Id("" + productVarinat + "" + q + "")).Text;
                        values = values + "\r\n" + varinats;
                        driver.FindElement(By.Id("" + productVarinat + "" + q + "")).Click();
                    }

                    else
                    {
                        break;
                    }
                }
                datarow.Newrow("Variants", "", values, "PASS", driver);
            }
        }