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);
            }
        }
 public void Footerhome(IWebDriver driver, string url, Datarow datarow)
 {
     try
     {
         Footer(driver, datarow, url);
         var image = new Imagevalidation();
         image.Homepageimage(driver, datarow);
     }
     catch (Exception ex)
     {
         var e = ex.ToString();
         datarow.Newrow("Exception", "Exception Not Expected", e, "FAIL", driver);
         _screenshot.Screenshotfailed(driver);
     }
 }
        public void UserJourn(Datarow datarow, IWebDriver driver, string url)
        {
            try
            {
                driver.Navigate().GoToUrl(url);

                string categorylink;
                string cat;
                string products;
                string productlink;
                var uRl = driver.PageSource;
                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;
                }

                var image = new Imagevalidation();
                new FooterTps();

                image.Homepageimage(driver, datarow);
                driver.Navigate().GoToUrl(url);

                Thread.Sleep(5000);
                new CookieDisclosure().Cookie(driver, datarow);

                driver.FindElement(By.XPath("" + categorylink + "" + cat + ""));
                driver.FindElement(By.XPath("" + categorylink + "" + cat + "")).Click();

                // Activate After Debug
                image.categoryimage(driver, datarow);

                // footer.Footer(driver, datarow);
                GetXpathCount(driver, categorylink);

                if (IsElementPresent(driver, By.XPath("" + categorylink + "[" + 1 + "]" + cat + "")))
                {
                    //*[@id="productList"]/article[1]/a/div[1]/img
                    // Category Image validation
                    image.categoryimage(driver, datarow);
                    driver.FindElement(By.XPath("" + categorylink + "[" + 1 + "]" + cat + "")).Click();

                    if (IsElementPresent(driver, By.XPath("" + products + "[" + 1 + "]" + productlink + "")))
                    {
                        driver.FindElement(By.XPath("" + products + "" + productlink + "")).Click();
                    }
                }

                var prod = new ProductsTps();
                prod.Product(driver, datarow);

                Thread.Sleep(5000);
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Exception Is Not Expected", e, "FAIL", driver);
                _screenshot.Screenshotfailed(driver);
            }
        }
        //Product page validations
        public void Product(IWebDriver driver, Datarow datarow)
        {
            var image = new Imagevalidation();
            try
            {
                var url = driver.PageSource;

                string producttitle;
                string addToBasket;
                string checkout;
                string basketvalue;
                var screenshot1 = new Screenshot();

                #region object reading

                if (url.Contains("user-scalable=yes"))
                {
                    producttitle = CollectionMapV2.Producttitle;
                    addToBasket = CollectionMapV2.Addtobasket;
                    checkout = CollectionMapV2.Checkout;
                    basketvalue = BasketV2.basketvalue;
                }
                else
                {
                    producttitle = CollectionMapV1.Producttitle;
                    addToBasket = CollectionMapV1.Addtobasket;
                    checkout = CollectionMapV1.Checkout;
                    basketvalue = BasketV1.basketvalue;
                }

                #endregion

                image.productImage(driver, datarow);
                new ProductDetail().Productdetail(driver, datarow);
                new ProductPrice().Price(driver, datarow);

                #region Product Title

                // Product Title
                var title = driver.FindElement(By.ClassName(producttitle)).Text;
                datarow.Newrow("Product Title", "", title, "PASS", driver);

                if (IsElementPresent(driver, By.ClassName(producttitle)) == false)
                {
                    datarow.Newrow("Product Title", "Product Title Element is Expected",
                                   "Product Title Element Not Found", "FAIL", driver);
                }

                #endregion

                #region Product Variant

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

                        if (couent != 1)
                        {
                                  IWebElement con = driver.FindElement(By.Id(" + productVarinat + "));
                                  IList<IWebElement> selectOptions = con.FindElements(By.TagName("option"));

                            string values = null;
                            foreach (IWebElement value in selectOptions)
                            {
                                if (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
                        {
                            string varinats = GetValue(driver, By.Id("" + productVarinat + ""));
                            datarow.newrow("Variants", "", varinats, "PASS",driver);
                        }
                    }
                    catch (Exception ex)
                    {
                        string e = ex.ToString();

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

                else if(IsElementPresent(driver,By.Id("" + productVarinat + "_0")))
                {
                    try
                    {
                        string values = null;
                        for (int q = 1;; q++)
                        {
                            if (IsElementPresent(driver,By.Id("" + productVarinat + "" + q + "")))
                            {
                                string varinats =  driver.FindElement(By.Id("" + productVarinat + "" + q + "")).Text;
                                if (varinats != "Please Select" || varinats != null)
                                {
                                    values = values + "\r\n" + varinats;
                                    driver.FindElement(By.Id("" + productVarinat + "" + q + "")).Click();
                                }
                            }

                            else
                            {
                                break;
                            }
                        }
                        datarow.newrow("Variants", "", values, "PASS",driver);
                    }
                    catch (Exception ex)
                    {
                        string e = ex.ToString();
                        throw;
                    }
                }
                else
                {
                    datarow.newrow("Variants", "", "No Variants", "PASS", driver);
                }

                #endregion

                #region V2 Product Variant

                if (url.Contains("user-scalable=yes"))
                {
                    if (IsElementPresent(driver,By.XPath("//a[@id='showOptions']/span")))
                    {
                        driver.FindElement(By.XPath("//a[@id='showOptions']/span")).Click();

                        IWebElement con = driver.FindElement(By.Id("Variants_1__OptionValue"));
                         IList<IWebElement> vainats = con.FindElements(By.TagName("option"));
                       ;
                        string vales = null;
                        foreach (IWebElement value in vainats)
                        {
                            if (value.Text != "Please Select")
                            {
                                vales = vales + "\r\n" + value;
                                new SelectElement(driver.FindElement(By.Id("Variants_1__OptionValue"))).SelectByText(value.Text);
                            }
                        }

                        datarow.newrow("Variants", "", vales, "PASS",driver);
                        if (IsElementPresent(driver,By.Id("" + productvariant2 + "_0")))
                        {
                            string values = null;
                            for (int q = 1;; q++)
                            {
                                if (IsElementPresent(driver,By.Id("" + productvariant2 + "_" + q + "")))
                                {
                                    string varinats =  driver.FindElement(By.Id("" + productvariant2 + "_" + q + "")).Text;
                                    if (varinats != "Please Select" || varinats != null)
                                    {
                                        values = values + "\r\n" + varinats;
                                        driver.FindElement(By.Id("" + productvariant2 + "_" + q + "")).Click();
                                    }
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }
            */

                #endregion

                try
                {
                    driver.FindElement(By.XPath(addToBasket)).Click();

                    datarow.Newrow("Add to Basket Button", "Add To Basket Button is Expected",
                                   addToBasket + "Add To Basket Element Is Present", "PASS", driver);
                    new SuccessMessage().Message(driver, datarow);
                }
                catch (Exception ex)
                {
                    var e = ex.ToString();
                    datarow.Newrow("Add to Basket Button", "Add To Basket Button is Expected", e, "FAIL", driver);
                    screenshot1.Screenshotfailed(driver);
                }

                var basval = driver.FindElement(By.XPath(basketvalue)).Text;

                if (basval == "(1)")
                {
                    datarow.Newrow("Basket Value", "(1)", basval, "PASS", driver);
                }
                else
                {
                    datarow.Newrow("Basket Value", "(1)", basval, "FAIL", driver);
                    screenshot1.Screenshotfailed(driver);
                }

                //Footer_TPS footer = new Footer_TPS();
                //footer.Footer(driver, datarow);

                driver.FindElement(By.Id("BasketInfo")).Click();

                new SelectElement(driver.FindElement(By.Id("Items_0__Quantity")));

                // driver.FindElement(By.Id()).Click();("css=option");
                var pric = driver.FindElement(By.CssSelector("strong")).Text;
                new SelectElement(driver.FindElement(By.Id("Items_0__Quantity"))).SelectByText("4");

                Thread.Sleep(3000);
                var prirc = driver.FindElement(By.CssSelector("strong")).Text;

                datarow.Newrow("Price Change with Quantity in Basket Page", pric, prirc, pric == prirc ? "FAIL" : "PASS",
                    driver);

                driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                driver.FindElement(By.XPath(checkout));
                if (url.Contains("user-scalable=yes") == false)
                {
                    var value1 = driver.FindElement(By.Id("BasketInfo")).Text;

                    if (value1 == "(4)")
                    {
                        datarow.Newrow("Basket Value", "(4)", value1, "PASS", driver);
                    }
                    else
                    {
                        datarow.Newrow("Basket Value", "(4)", value1, "FAIL", driver);
                        screenshot1.Screenshotfailed(driver);
                    }
                }
                new SelectElement(driver.FindElement(By.Id("Items_0__Quantity")));
            }
            catch (Exception ex)
            {
                var e = ex.ToString();
                datarow.Newrow("Exception", "Exception Not Expected", e, "FAIL", driver);
                _screenshot.Screenshotfailed(driver);
            }
        }