public void SearchSkills() { //Populate data from Excel GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "SearchSkills"); //wait for skill searchbox GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.driver, By.XPath("//input[@placeholder='Search skills']"), 10); //Enter skill in skill search searchSkills.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill")); searchSkills.SendKeys(Keys.Enter); // wait for All categories GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//b[contains(text(),'All Categories')])", "XPath"); //click on all category GlobalDefinitions.driver.FindElement(By.XPath("//b[contains(text(),'All Categories')]")).Click(); //wait for category GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//a[@role = 'listitem' and text() ='Graphics & Design']"), 10); //click on category GlobalDefinitions.driver.FindElement(By.XPath("//a[@role = 'listitem' and text() ='Graphics & Design']")).Click(); Base.Test.Log(LogStatus.Pass, "Search Skill by category successfully"); //wait for sub category GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.driver, By.XPath("//a[@role = 'listitem' and text() = 'Logo Design']"), 10); //click on sub category GlobalDefinitions.driver.FindElement(By.XPath("//a[@role = 'listitem' and text() = 'Logo Design']")).Click(); Base.Test.Log(LogStatus.Pass, "Search Skill by sub category successfully"); //click onsite GlobalDefinitions.driver.FindElement(By.XPath("//button[contains(text(),'Onsite')]")).Click(); GlobalDefinitions.wait(10); //click on online GlobalDefinitions.driver.FindElement(By.XPath("//button[contains(text(),'Online')]")).Click(); //click on chat button chatButton.Click(); //click on notification GlobalDefinitions.driver.FindElement(By.XPath("//div[@class='ui top left pointing dropdown item']")).Click(); }
public void DeleteListing() { manageListing.Click(); //Populate data from Excel GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "SkillShare"); //wait for manage listing GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//h2[contains(text(),'Manage Listings')]"), 10); while (true) { for (int j = 1; j <= 5; j++) { GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//tr[1]//td[3]"), 10); var categoryObj = GlobalDefinitions.driver.FindElement(By.XPath("//tr[" + j + "]//td[2]")).Text; var titleObj = GlobalDefinitions.driver.FindElement(By.XPath("//tr[" + j + "]//td[3]")).Text; Console.WriteLine(titleObj); Console.WriteLine(categoryObj); IWebElement deleteListing = Global.GlobalDefinitions.driver.FindElement(By.XPath("//tr[" + j + "]//td[8]//i[3]")); GlobalDefinitions.wait(10); if (titleObj == GlobalDefinitions.ExcelLib.ReadData(2, "Title") && categoryObj == "Writing & Translation") { //wait for delete btn GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//tr[" + j + "]//td[8]//i[3])", "XPath"); deleteListing.Click(); //wait for accept btn GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//button[@class='ui icon positive right labeled button'])", "XPath"); acceptBtn.Click(); Base.Test.Log(LogStatus.Pass, "Skill deleted successfully, Test passed"); return; } } //click next page nextPageBtn.Click(); } }
public void Requests() { Actions manageRequestaction = new Actions(GlobalDefinitions.driver); manageRequestaction.MoveToElement(GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(text(), 'Manage Requests')]"))).Click().Build().Perform(); //wait for Recieved Request GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//a[contains(text(),'Received Requests')])", "XPath"); //click on recieved requests recievedRequests.Click(); Base.Test.Log(LogStatus.Pass, "open Recieved Request, Test passed"); Actions action = new Actions(GlobalDefinitions.driver); action.MoveToElement(GlobalDefinitions.driver.FindElement(By.XPath("//div[contains(text(), 'Manage Requests')]"))).Click().Build().Perform(); //wait for sent requests GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//a[contains(text(),'Sent Requests')])", "XPath"); //click on sent requets sentRequests.Click(); Base.Test.Log(LogStatus.Pass, "open send requests, Test passed"); }
internal void LoginSteps() { //extent Reports Base.Test = Base.Extent.StartTest("Login Test"); //Populate the Excel sheet Global.GlobalDefinitions.ExcelLib.PopulateInCollection(Global.Base.ExcelPath, "SignIn"); //Navigate to the Url Global.GlobalDefinitions.driver.Navigate().GoToUrl(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Url")); //Click on Sign In tab SignIntab.Click(); Thread.Sleep(500); //Enter the data in Username textbox Email.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Username")); Thread.Sleep(500); //Enter the password Password.SendKeys(Global.GlobalDefinitions.ExcelLib.ReadData(2, "Password")); //Click on Login button LoginBtn.Click(); GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//a[@class='ui basic green button'])", "XPath"); var text = Global.GlobalDefinitions.driver.FindElement(By.XPath("//a[contains(text(),'Mars Logo')]")).Text; Console.WriteLine(text); Thread.Sleep(1000); if (text == "Mars Logo") { Global.Base.Test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Login Successful"); } else { Global.Base.Test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Login Unsuccessful"); } }
public void UpdatedListing() { manageListing.Click(); //Populate data from Excel GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "SkillShare"); SkillSharePage updSkillObj = new SkillSharePage(); //wait for manage listing GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//h2[contains(text(),'Manage Listings')]"), 10); while (true) { for (int j = 1; j <= 5; j++) { GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//tr[1]//td[3]"), 10); var categoryObj = Global.GlobalDefinitions.driver.FindElement(By.XPath("//tr[" + j + "]//td[2]")).Text; var titleObj = GlobalDefinitions.driver.FindElement(By.XPath("//tr[" + j + "]//td[3]")).Text; IWebElement updateListing = GlobalDefinitions.driver.FindElement(By.XPath("//tr[" + j + "]//td[8]//i[2]")); GlobalDefinitions.wait(10); if (titleObj == "ttt" && categoryObj == "Programming & Tech") { //wait for update btn GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//tr[" + j + "]//td[8]//i[2])", "XPath"); updateListing.Click(); GlobalDefinitions.wait(10); updSkillObj.SkillShare(); Base.Test.Log(LogStatus.Pass, "Skill updated successfully, Test passed"); return; } } //click next page nextPageBtn.Click(); } }
public void SkillShare() { //wait for Skill share button GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//a[contains(text(), 'Share Skill')])", "XPath"); //Populate data from Excel GlobalDefinitions.ExcelLib.PopulateInCollection(Base.ExcelPath, "SkillShare"); shareSkillBtn.Click(); //wait for Title textbox GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//h3[contains(text(),'Title')]"), 10); //add Title addTitle.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Title")); Base.Test.Log(LogStatus.Pass, "Add Title Successfully, Test passed"); //add Description addDescription.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Description")); Base.Test.Log(LogStatus.Pass, "Add Description Successfully, Test passed"); // wait for Select Category GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//select[@name='categoryId'])", "XPath"); //select category SelectElement categoryObj = new SelectElement(addCategory); categoryObj.SelectByText(GlobalDefinitions.ExcelLib.ReadData(2, "Category")); Base.Test.Log(LogStatus.Pass, "Add category successfully, Test passed"); // wait for sub category GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//select[@name='subcategoryId'])", "XPath"); //Select Sub Category SelectElement subCategoryObj = new SelectElement(addSubCategory); subCategoryObj.SelectByValue(GlobalDefinitions.ExcelLib.ReadData(2, "SubCategory")); Base.Test.Log(LogStatus.Pass, "Add subcategory successfully, Test passed"); //add Tags addTags.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Tags")); addTags.SendKeys(Keys.Enter); Base.Test.Log(LogStatus.Pass, "Add Tags successfully, Test passed"); //Select Service Type switch (GlobalDefinitions.ExcelLib.ReadData(2, "Location")) { case "One-off service": oneOffService.Click(); break; case "Hourly basis service": hourlyService.Click(); break; } Base.Test.Log(LogStatus.Pass, "Service is selcted successfully, Test passed"); //select location type switch (GlobalDefinitions.ExcelLib.ReadData(2, "Location")) { case "On-site": onsiteBtn.Click(); break; case "online": onlineBtn.Click(); break; } Base.Test.Log(LogStatus.Pass, "Location is selected successfully, Test passed"); //wait for start date GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//input[@placeholder='Start date'])", "XPath"); startDate.Clear(); startDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "StartDate")); Base.Test.Log(LogStatus.Pass, "Add start date, Test passed"); //Press tab to shift focus to End date startDate.SendKeys(Keys.Tab); //Enter End date endDate.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "EndDate")); Base.Test.Log(LogStatus.Pass, "Add End Date, Test passed"); //Press tab to shift focus to End date endDate.SendKeys(Keys.Tab); //count number of days int noOfDays = GlobalDefinitions.driver.FindElements(By.Name("Available")).Count(); var i = 1; while (i <= noOfDays) { var daysObj = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (i + 1) + "]/div[1]/div/label")).Text; var daysChekBox = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (i + 1) + "]/div[1]/div/input")); var startTime = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (i + 1) + "]/div[2]/input")); var endTime = GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='service-listing-section']/div[2]/div/form/div[7]/div[2]/div/div[" + (i + 1) + "]/div[3]/input")); switch (daysObj) { case "Sun": daysChekBox.Click(); daysChekBox.SendKeys(Keys.Tab); startTime.SendKeys("0940am"); daysChekBox.SendKeys(Keys.Tab); endTime.SendKeys("0500pm"); goto Start; case "Tue": daysChekBox.Click(); daysChekBox.SendKeys(Keys.Tab); startTime.SendKeys("0800am"); daysChekBox.SendKeys(Keys.Tab); endTime.SendKeys("0310pm"); goto Start; case "Sat": daysChekBox.Click(); daysChekBox.SendKeys(Keys.Tab); startTime.SendKeys("0800am"); daysChekBox.SendKeys(Keys.Tab); endTime.SendKeys("0310pm"); break; } Start: i++; } Base.Test.Log(LogStatus.Pass, "Add Available days and time, Test passed"); //Select SkillTrade switch (GlobalDefinitions.ExcelLib.ReadData(2, "Skill Trade")) { case "Skill-exchange": selectSkillExchange.Click(); GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.driver, By.XPath("//div[@class='form-wrapper']//input[@placeholder='Add new tag']"), 10); skillExchange.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Skill-Exchange")); break; case "Credit": selectCredit.Click(); GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.driver, By.XPath("//input[@placeholder='Amount']"), 10); credit.SendKeys(GlobalDefinitions.ExcelLib.ReadData(2, "Credit")); break; } Base.Test.Log(LogStatus.Pass, "Add skill Trade, Test passed"); //Wait for work sample GlobalDefinitions.WaitForElement(Global.GlobalDefinitions.driver, By.XPath("//i[@class='huge plus circle icon padding-25']"), 10); //select file for work sample uploadFile.Click(); //create a AutoIT class and object AutoItX3 autoIt = new AutoItX3(); autoIt.WinActivate("Open"); GlobalDefinitions.wait(100); autoIt.Send(GlobalDefinitions.ExcelLib.ReadData(2, "WorkSamples")); GlobalDefinitions.wait(100); autoIt.Send("{Enter}"); Base.Test.Log(LogStatus.Pass, "WorkSample uploaded, Test passed"); GlobalDefinitions.WaitForElement(GlobalDefinitions.driver, By.XPath("//label[text() = 'Active']"), 10); // Select Active switch (GlobalDefinitions.ExcelLib.ReadData(2, "IsActive")) { case "Hidden": hiddenBtn.Click(); break; case "Active": activeBtn.Click(); break; } Base.Test.Log(LogStatus.Pass, "Is Active selected, Test passed"); //wait for save button GlobalDefinitions.waitUntilClickable(GlobalDefinitions.driver, 1000, "(//input[@value = 'Save'])", "XPath"); //click Save saveBtn.Click(); }