[Test, Order(1)] //Identifying method as TestCase and specifying the execution order public void Verify_AddProductToCart(string browserName) { NavigateToHomePage(browserName); //DataTable rCnt = Excel_Library.GetNumberOfRows(@"C:\Users\Karthee\Desktop\Login_Credentials.xlsx", "Sheet1"); // DataTable rCnt = Excel_Library.GetNumberOfRows(@"C:\Users\sriramdasbalaji\Source\Repos\Selenium\test\PartsUnlimited.SeleniumTests\Excel_Files\Login_Credentials.xlsx", "Sheet1"); string email = "*****@*****.**"; //Convert.ToString(rCnt.Rows[0]["Email"]); string password = "******"; //Convert.ToString(rCnt.Rows[0]["Password"]); //------ Login to application --------------- //Click on Login icon PropertiesCollection.LoginObject.clickLoginBtn(); Base_Class.Wait(); //Implicit wait of 3000ms //Type in Email ID and Password PropertiesCollection.LoginObject.Type_Email(email); PropertiesCollection.LoginObject.Type_Password(password); //Click on Login button PropertiesCollection.LoginObject.clickLoginOnPage(); Base_Class.Wait(); //------ Adding product/s to cart page --------------- //Scroll till element "Synthetic Engine oil" using Javascript IJavaScriptExecutor js = PropertiesCollection.driver as IJavaScriptExecutor; js.ExecuteScript("window.scroll(0, 1500);"); Base_Class.Wait(); //Identifying the product and add to cart if (PropertiesCollection.CartPageObjects.AlloyRim.Displayed) { PropertiesCollection.CartPageObjects.Click_AlloyRim(); //Click on item Base_Class.Wait(); PropertiesCollection.CartPageObjects.Click_AddtoCart(); //Click on Add to cart button Base_Class.Wait(); //cartValue = PropertiesCollection.CartPageObjects.cartCount.Text; //Storing the cart-count in var "Cart_Value" Console.WriteLine("Items added to cart page. Following are the product details:\n"); Base_Class.Wait(); //Identifying the number of product/s in cart page IList <IWebElement> summary = PropertiesCollection.driver.FindElements(By.XPath("//div[@class='row']/div[5]/div[1]/strong/a")); //Displaying the cart summary details foreach (var item in summary) { Console.WriteLine(item.Text + "\n"); } } else { Console.WriteLine("Search item could not be found.\n"); } }
public void navigatehomepage(string browserName) { NavigateToHomePage(browserName); //string email = "*****@*****.**";//Convert.ToString(rCnt.Rows[0]["Email"]); //string password = "******";//Convert.ToString(rCnt.Rows[0]["Password"]); //wait Base_Class.Wait(); }
public void Verify_Login(string browserName) { NavigateToHomePage(browserName); //DataTable rCnt = Excel_Library.GetNumberOfRows(HostingEnvironment.MapPath(@".\Login_Credentials.xlsx", "Sheet1")); string email = "*****@*****.**"; //Convert.ToString(rCnt.Rows[0]["Email"]); string password = "******"; //Convert.ToString(rCnt.Rows[0]["Password"]); //wait Base_Class.Wait(); //Click on Login button PropertiesCollection.LoginObject.clickLoginBtn(); //wait Base_Class.Wait(); //Enter Email ID from excel PropertiesCollection.LoginObject.Type_Email(email); //Enter Password from excel PropertiesCollection.LoginObject.Type_Password(password); Base_Class.Wait(); //Click on Login button PropertiesCollection.LoginObject.clickLoginOnPage(); //Displays when there is no validation message Console.WriteLine(" User logged into 'PartsUnlimited' application succesfully. "); //wait //Base_Class.Wait(); //Click on Profile field //PropertiesCollection.LoginObject.clickProfile(); //wait //Base_Class.Wait(); //Click on Manage User link //PropertiesCollection.LoginObject.clickManageUser(); //wait //Base_Class.Wait(); //Get the logged in user email id //String Username = PropertiesCollection.driver.FindElement(By.XPath("//dd[contains(text(),'" + UserName + "')]")).Text; //Console.WriteLine("Logged In Email ID is : " + Username); }
public void Verify_Logout(string browserName) { NavigateToHomePage(browserName); // DataTable rCnt = Excel_Library.GetNumberOfRows(@"C:\Users\sriramdasbalaji\Source\Repos\Selenium\test\PartsUnlimited.SeleniumTests\Excel_Files\Login_Credentials.xlsx", "Sheet1"); string email = "*****@*****.**"; //Convert.ToString(rCnt.Rows[0]["Email"]); string password = "******"; //Convert.ToString(rCnt.Rows[0]["Password"]); //wait Base_Class.Wait(); //Click on Login button PropertiesCollection.LoginObject.clickLoginBtn(); //wait Base_Class.Wait(); //Enter Email ID from excel PropertiesCollection.LoginObject.Type_Email(email); //Enter Password from excel PropertiesCollection.LoginObject.Type_Password(password); //Click on Login button PropertiesCollection.LoginObject.clickLoginOnPage(); //wait Base_Class.Wait(); //Click on Profile field PropertiesCollection.LoginObject.clickProfile(); //wait Base_Class.Wait(); //Click on Logout button PropertiesCollection.LoginObject.clickLogOffBtn(); //Displays when there is no validation message Console.WriteLine(" User logged out from 'PartsUnlimited' application succesfully. "); }