public void Productunavailabl(IWebDriver driver, int l, Datarow datarow) { string deletebasket; string homeimage; var url = driver.PageSource; if (url.Contains("user-scalable=yes")) { deletebasket = CollectionMapV2.Deletebasket; homeimage = CollectionMapV2.Homeimage; } else { deletebasket = CollectionMapV1.Deletebasket; homeimage = CollectionMapV1.Homeimage; } try { if (IsElementPresent(driver, By.XPath("//body[@id='Top']/div/div[2]/div[2]/ul/li[2]/a/span"))) { driver.FindElement(By.XPath("//body[@id='Top']/div/div[2]/div[2]/ul/li[2]/a/span")).Click(); } else if (IsElementPresent(driver, By.Id(deletebasket))) { driver.FindElement(By.XPath(deletebasket)).Click(); } driver.FindElement(By.Id(homeimage)).Click(); var url1 = driver.PageSource; string products; string productlink; string categorylink; string cat; if (url1.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; } //body[@id='Top']/div/div[2]/div[2]/ul/li[2]/a/span driver.FindElement(By.XPath("" + categorylink + "" + cat + "")).Click(); GetXpathCount(driver, categorylink); for (var i = 1;; i++) { if (IsElementPresent(driver, By.XPath("" + categorylink + "[" + l + "]" + cat + ""))) { driver.FindElement(By.XPath("" + categorylink + "[" + l + "]" + cat + "")).Click(); if (!IsElementPresent(driver, By.XPath(products))) continue; driver.FindElement(By.Id("" + products + "" + productlink + "")).Click(); } break; } var product = new ProductsTps(); product.Product(driver, datarow); } catch (Exception ex) { var e = ex.ToString(); datarow.Newrow("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); } }
private void Basketvalidation(IWebDriver driver, Datarow datarow) { string products; string productlink; string categorylink; string cat; string homeimage; var url = driver.PageSource; if (url.Contains("user-scalable=yes")) { categorylink = CollectionMapV2.Categorylink; cat = CollectionMapV2.Cat; products = CollectionMapV2.Products; homeimage = CollectionMapV2.Homeimage; productlink = CollectionMapV2.Productlink; } else { categorylink = CollectionMapV1.Categorylink; cat = CollectionMapV1.Cat; products = CollectionMapV1.Products; homeimage = CollectionMapV1.Homeimage; productlink = CollectionMapV1.Productlink; } try { if (!url.Contains("user-scalable=yes")) { var value = driver.FindElement(By.Id("BasketInfo")).Text; if (value == "(0)") { datarow.Newrow("Delete Basket Value", "(0)", value, "PASS", driver); } else { datarow.Newrow("Delete Basket Value", "(0)", value, "FAIL", driver); _screenshot.Screenshotfailed(driver); } } //.Click("//*[@id='UpdateBasketForm']/div/div[2]/a/span/span"); // waitforpagetoload("30000"); driver.FindElement(By.ClassName(homeimage)).Click(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10)); driver.FindElement(By.XPath("" + categorylink + "" + cat + "")); driver.FindElement(By.XPath("" + categorylink + "" + cat + "")).Click(); decimal categorycount = driver.FindElements(By.XPath(categorylink)).Count; for (var i = 1;; i++) { if (IsElementPresent(driver, By.XPath("" + categorylink + "" + cat + ""), 30)) { driver.FindElement(By.XPath("" + categorylink + "" + cat + "")).Click(); if (IsElementPresent(driver, By.XPath(products), 30)) { driver.FindElement(By.XPath("" + products + "" + productlink + "")).Click(); } else { break; } } else { break; } } var prd = new ProductsTps(); prd.Product(driver, datarow); driver.FindElement(By.XPath("//a[@id='GoToCheckout']/span/span")).Click(); } catch (Exception ex) { var e = ex.ToString(); datarow.Newrow("Exception", "Exception Not Expected", e, "FAIL", driver); _screenshot.Screenshotfailed(driver); } }