internal void ValidateAddSkill() { //Validate the Skill is added sucessfully try { //skills test SkillsButton.Click(); String skill = driver.FindElement(By.XPath("(//div[@data-tab='second']//table//tbody//tr[1]//td[1])[1]")).Text; Assert.AreEqual(skill, ExcelLibHelper.ReadData(2, "Skills")); //skill Level test String skilllevel = driver.FindElement(By.XPath("(//div[@data-tab='second']//table//tbody//tr[1]//td[2])[1]")).Text; Assert.AreEqual(skilllevel, ExcelLibHelper.ReadData(2, "SkillLevel")); SaveScreenShotClass save = new SaveScreenShotClass(); string img = save.SaveScreenshot(driver, "SkillAdd"); } catch (Exception) { Assert.Fail(); } ExtentionHelpers.TurnOnWait(driver); }
public static void SigninStep() { Driver.NavigateUrl(); SignInBtn.Click(); Email.SendKeys(ExcelLibHelper.ReadData(2, "Username")); Password.SendKeys(ExcelLibHelper.ReadData(2, "Password")); LoginBtn.Click(); try { //Start the Reports CommonMethods.ExtentReports(); Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("SignIn to Mars"); WaitHelpers.WaitForElement(Driver.driver, "XPath", "//*[contains(text(),'Ishaan Sandeep')]", 10000); // check login is successfull var loginCheck = "test"; loginCheck = Driver.driver.FindElement(By.XPath("//*[contains(text(),'Ishaan Sandeep')]")).GetAttribute("innerText"); if (loginCheck == "Ishaan Sandeep") { CommonMethods.test.Log(LogStatus.Pass, "Login Passed"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Login Passed"); Assert.IsTrue(true); } else { CommonMethods.test.Log(LogStatus.Fail, "Login failed"); } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed", e.Message); } }
//Update the existing Certification internal void UpdateCertification() { //Get the Certification value needs to be updated String expectedValue = ExcelLib.ReadData(2, "CertificationName"); //Get the rows count in Certification table IList <IWebElement> Tablerows = Driver.FindElements(By.XPath("//h3[contains(text(),'Certification')]/../..//table/tbody/tr")); var rowCount = Tablerows.Count; //Get the actual Certification value and compare with Certification needs to be updated, if matches update the record for (int i = 1; i <= rowCount; i++) { String actualValue = Driver.FindElement(By.XPath("//h3[contains(text(),'Certification')]/../..//tbody[" + i + "]/tr/td[1]")).Text; if (expectedValue == actualValue) { //Click on Edit icon Driver.FindElement(By.XPath("//h3[contains(text(),'Certification')]/../..//tbody[" + i + "]/tr/td[4]/span[1]/i")).Click(); //Clear the existing value and add new value Extension.WaitForElementDisplayed(Driver, By.Name("certificationName"), 2); AddCertificationName.Clear(); AddCertificationName.SendKeys(ExcelLib.ReadData(2, "UpdateCertificationName")); AddCertificationFrom.Clear(); AddCertificationFrom.SendKeys(ExcelLib.ReadData(2, "UpdateCertificationFrom")); SelectDropDown(ChooseCertificationYear, "SelectByValue", ExcelLib.ReadData(2, "UpdateCertificationYear")); //Click update button UpdateCertificationButton.Click(); Base.Image = SaveScreenShotClass.SaveScreenshot(Driver, "Report"); //Validate message Extension.MessageValidation(ExcelLib.ReadData(2, "UpdateCertificationName") + " has been updated to your certification"); } } }
public void ThenThatLanguageShouldBeDeleted() { try { var LanguageToDelete = ScenarioContext.Current["ToDelete"]; string ExpectedLanguageDeleted = LanguageToDelete.ToString(); bool LanguageDelete = CommonMethods.ElementVisible(Driver.driver, "XPath", "//td[contains(text()," + ExpectedLanguageDeleted + ",)]"); if (LanguageDelete) { CommonMethods.test.Log(LogStatus.Fail, "LanguageDeleteFailed"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageDeleteFail"); } else { CommonMethods.test.Log(LogStatus.Pass, "LanguageDeleted Succesfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageDeleted Successfully"); } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "LanguageDeleteFailed" + e.Message); } }
public void ThenThatSkillShouldBeDisplayedOnMyListings() { try { //Start the Reports CommonMethods.ExtentReports(); Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("Add a Skill"); int tempValue = 0; Thread.Sleep(1000); //Find the no of Table body IReadOnlyCollection <IWebElement> NoOfRows = Driver.driver.FindElements(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[3]/div/div[2]/div/table/tbody")); for (int i = 1; i <= NoOfRows.Count; i++) { string ExpectedValue = "C++"; string ActualValue = Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[3]/div/div[2]/div/table/tbody[" + i + "]/tr/td[1]")).Text; Thread.Sleep(500); if (ExpectedValue == ActualValue) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Added a Skill Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "SkillAdded"); tempValue++; return; } } if (tempValue == 0) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed", e.Message); } }
//A method to enter and save a given test data set for finance details internal bool SaveFinanceDetails(int TestDataSet) { try { //Enter the testdata into the relevant input fields PurchasePrice.SendKeys(ExcelLib.ReadData(TestDataSet, "PurchasePrice")); Mortgage.SendKeys(ExcelLib.ReadData(TestDataSet, "Mortgage")); HomeValue.SendKeys(ExcelLib.ReadData(TestDataSet, "HomeValue")); Thread.Sleep(1000); //Click on the Next Button to move to the Tenant Details FinanceNextButton.Click(); return(true); } catch (Exception e) { // Add details of the error into the report Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Error, "Error occured when entering Finance Details for the new property: " + e.Message.ToString()); // Save Screenshot to display the error String img = SaveScreenShotClass.SaveScreenshot(Driver.driver, "Exception Report"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Image example: " + img); return(false); } }
public void ThenThatPasswordShouldBeChanged() { try { CommonMethods.ExtentReports(); //extent Reports CommonMethods.test = CommonMethods.extent.StartTest("Change Password test"); string ChangePasswordSuccess = Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/div/div/div/h3")).Text; if (ChangePasswordSuccess == "Description") { CommonMethods.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Password changed successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Password changed successfully"); } else { CommonMethods.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Password not changed successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Password changed successfully"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void ThenThatLanguageShouldBeDisplayedOnMyListings() { try { //Start the Reports // CommonMethods.ExtentReports(); Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("Add a Language"); Thread.Sleep(1000); string ExpectedValue = "English"; string ActualValue = Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/table/tbody/tr/td[1]")).Text; Thread.Sleep(500); //Cleanup Language for next execution if (ExpectedValue == ActualValue) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Added a Language Successfully"); Thread.Sleep(500); imageFile = SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageAdded"); Driver.driver.FindElement(By.XPath("//table[@class='ui fixed table']/tbody/tr/td[3]/span[2]/i")).Click(); Thread.Sleep(500); } else { CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); imageFile = SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguagenotAdded"); } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed", e.Message); imageFile = SaveScreenShotClass.SaveScreenshot(Driver.driver, "ExceptioninLanguageAdded"); } }
public void ThenTheResultsShouldBeDisplayedBasedOnSearch() { try { CommonMethods.ExtentReports(); //extent Reports CommonMethods.test = CommonMethods.extent.StartTest("Search test"); IWebElement Results = Driver.driver.FindElement(By.XPath("//*[@id='service-search-section']/div[2]/div/section/div/div[1]/div[1]/h3")); if (Results.Text == "Refine Results") { CommonMethods.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Results shown successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Results shown successfully"); } else { CommonMethods.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Results not shown successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Results not shown successfully"); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
internal void DeleteListingSkills() { //Click on Manage LIsting tab MgmtListTab.Click(); Thread.Sleep(1000); // Delete skills form managelisting page DeleteIcon.Click(); try { //Check the popup "Delete your service" is present or not if (PopUp != null) { //If yes button found,then click on it and Navigate to Managelisting page YesBtn.Click(); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Yes button found on popup "); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Yes button found on popup"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Yes button is not found on popup "); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Yes button found on popup"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } } catch (Exception e) { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Yes button is not present in Delete service popup " + e.Message); string screenshotpath = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Yes button is not present in Delete service popup"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Snapshot below:" + Base.test.AddBase64ScreenCapture(screenshotpath)); } }
public void DeleteLanguage() { // Creates a toggle for the given test, adds all log events under it test = extent.StartTest("Delete Language"); try { Profile profileObj = new Profile(); profileObj.DeleteLanguage(); //If Action Performed succesfully, record can not be found from Language table string ExpectedResult = "Spanish"; Assert.IsFalse(profileObj.CheckLanguageTable(ExpectedResult)); // Screenshot string img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Add Language"); test.Log(LogStatus.Info, "Language Deleted Successfully" + img); } catch (Exception e) { Base.test.Log(LogStatus.Error, "Error in delete Language : " + e.Message); } }
//Method to create a new rental listing for a property internal bool SaveRentalListing(int TestDataSet) { //Navigate into the "List Rental Property" page NavigateToPage(); try { //Select the property to be listed SelectElement SelectedProperty = new SelectElement(SelectPropertyMenu); //SelectedProperty.SelectByIndex(Convert.ToInt32(ExcelLib.ReadData(TestDataSet, "Property Index"))); SelectedProperty.SelectByText(ExcelLib.ReadData(TestDataSet, "Address")); //Enter test data for the listing TitleTextBox.SendKeys(ExcelLib.ReadData(TestDataSet, "Title")); DescriptionTextArea.SendKeys(ExcelLib.ReadData(TestDataSet, "Description")); MovingCostTextBox.SendKeys(ExcelLib.ReadData(TestDataSet, "Moving Cost")); TargetRentTextBox.SendKeys(ExcelLib.ReadData(TestDataSet, "Target Rent")); AvailableDateDatePicker.SendKeys(ExcelLib.ReadData(TestDataSet, "Available Date")); OccupantsCountTextBox.SendKeys(ExcelLib.ReadData(TestDataSet, "Occupants Count")); //Save the new listing SaveButton.Click(); //Confirm the action of saving a new listing Driver.driver.SwitchTo().Alert().Accept(); return(true); } catch (Exception e) { // Log the error details in the report Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Error, "Error occured when listing a property for rental: " + e.Message.ToString()); // Save Screenshot to display the error String img = SaveScreenShotClass.SaveScreenshot(Driver.driver, "Exception Report"); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Image example: " + img); return(false); } }
public void ThenIShouldBeRegistered() { try { //Start the Reports CommonMethods.ExtentReports(); CommonMethods.Wait(10); CommonMethods.Test = CommonMethods.Extent.StartTest("Add new user"); Thread.Sleep(1000); string expectedValue = "Registration Successfully, Please verify your email!"; string actualValue = Driver.driver.FindElement(By.XPath("//div[contains(@class,'ns-box-inner')]")).Text; Thread.Sleep(1000); if (expectedValue == actualValue) { CommonMethods.Test.Log(LogStatus.Pass, "Test Passed, Added User details Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "User Details Added"); } } catch (Exception e) { CommonMethods.Test.Log(LogStatus.Fail, "Test Failed", e.Message); } }
public void ThenThatDescriptionShouldBeAdded() { try { CommonMethods.ExtentReports(); // Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("Description Details"); IWebElement Description = Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/div/div/div/span")); if (CommonMethods.ExcelLib.ReadData(2, "Description") == Description.Text) { CommonMethods.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Description added Successful"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Description added"); } else { CommonMethods.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Adding Unsuccessful"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Adding Description Unsuccessful"); } } catch (Exception ex) { Assert.Fail(ex.Message); } }
//Validate update language internal void ValidateUpdateLanguage() { try { //check language LanguageButton.Click(); ExtentionHelpers.TurnOnWait(driver); //Lanuguage text //String Lang = Driver.driver.FindElement(By.XPath("//a[@class='item'][contains(.,'Languages')]")).Text; String Lang = driver.FindElement(By.XPath("(//div[@data-tab='first']//table//tbody//tr[1]//td[1])[1]")).Text; //Level Text String level = driver.FindElement(By.XPath("(//div[@data-tab='first']//table//tbody//tr[1]//td[2])[1]")).Text; //Assertions Assert.Multiple(() => { ExcelLibHelper.PopulateInCollection(ConstantHelpers.TestDataPath, "FieldValues"); Assert.AreEqual(Lang, ExcelLibHelper.ReadData(4, "Language")); Assert.AreEqual(level, "Basic"); }); SaveScreenShotClass save = new SaveScreenShotClass(); string img = save.SaveScreenshot(driver, "LanguageUpdate"); Console.WriteLine("Assertion pass"); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void ThenCancelledLanguageShouldNotBeDisplayedOnMyListings() { try { CommonMethods.ExtentReports(); Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("cancel addind a Language"); //Start the Reports IList <IWebElement> Languages = Driver.driver.FindElements(By.XPath("//th[text()='Language']//ancestor::thead//following-sibling::tbody")); int count = Languages.Count(); String beforeXPath = "//th[contains(text(),'Language')]//ancestor::thead//following-sibling::tbody["; String AfterXPath = "]/tr/td"; bool LangFound; for (int i = 0; i <= count; i++) { if (Driver.driver.FindElement(By.XPath(beforeXPath + i + AfterXPath)).Text == "french") { LangFound = true; CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); } else { LangFound = false; Console.WriteLine("Adding language cancelled successfully"); CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Cancelled a Language Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageCancelled"); } } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed", e.Message); } }
public void ThenTheEducationDetailsShouldBeDeleted() { try { //Start the Reports CommonMethods.ExtentReports(); Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("Delete a Education"); int tempValue = 0; Thread.Sleep(1000); //Find the no of Table body IReadOnlyCollection <IWebElement> NoOfRows = Driver.driver.FindElements(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[4]/div/div[2]/div/table/tbody")); for (int i = 1; i <= NoOfRows.Count; i++) { tempValue = 1; string ExpectedValue = CommonMethods.ExcelLib.ReadData(2, "DeleteEducation"); string ActualValue = Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[4]/div/div[2]/div/table/tbody[" + i + "]/tr/td[3]")).Text; Thread.Sleep(500); if (ExpectedValue == ActualValue) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); return; } } if ((NoOfRows.Count) == 0 || tempValue == 1) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Deleted Education Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "EducationDeleted"); } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed", e.Message); } }
//Delete Added Skill----------------// internal void DeleteSkill() { Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr/td[8]/i[3]")).Click(); Global.GlobalDefinitions.wait(5); YesButton.Click(); Global.GlobalDefinitions.wait(5); Global.GlobalDefinitions.wait(5); Global.GlobalDefinitions.driver.FindElement(By.XPath("//html/body")); GlobalDefinitions.driver.SwitchTo().DefaultContent(); Thread.Sleep(500); // Creates a toggle for the given test, adds all log events under it test = extent.StartTest("Delete Skill Test"); try { string ExpectedText1 = Global.GlobalDefinitions.ExcelLib.ReadData(2, "Description"); string ActualText1 = Global.GlobalDefinitions.driver.FindElement(By.XPath("//*[@id='listing-management-section']/div[2]/div[1]/table/tbody/tr/td[4]")).Text; if (ExpectedText1.Equals(ActualText1)) { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Fail, "Delete Skill UnSuccessful"); String img2 = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "DeleteSkill_Fail"); test.Log(LogStatus.Info, "Image example: " + img2); } } catch (NoSuchElementException) { Global.Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Pass, "Delete Skill Successful"); String img3 = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "DeleteSkill_Pass"); test.Log(LogStatus.Info, "Image example: " + img3); } }
public void TearDown() { //Get test restult var status = TestContext.CurrentContext.Result.Outcome.Status; var stacktrace = "<pre>" + TestContext.CurrentContext.Result.StackTrace + "</pre>"; var errorMessage = TestContext.CurrentContext.Result.Message; // Screenshot string screenShotPath = SaveScreenShotClass.SaveScreenshot(Driver, TestContext.CurrentContext.Test.Name); // Write log to report LogStatus logstatus; switch (status) { case TestStatus.Failed: logstatus = LogStatus.Fail; test.Log(logstatus, "Test ended with " + logstatus + "–" + stacktrace + errorMessage); test.Log(LogStatus.Info, "Snapshot below:" + test.AddScreenCapture(screenShotPath)); break; case TestStatus.Passed: logstatus = LogStatus.Pass; test.Log(logstatus, "Test ended with " + logstatus); test.Log(LogStatus.Info, "Snapshot below:" + test.AddScreenCapture(screenShotPath)); break; } // end test. (Reports) extent.EndTest(test); // calling Flush writes everything to the log file (Reports) extent.Flush(); // Close the driver Driver.Close(); Driver.Quit(); }
public void ThenLogOutAndLoginAgain_AlreadyCreatedProfileIsDisplayed() { Driver.driver.FindElement(By.XPath("/ html / body / div[1] / div / div[1] / div[2] / div / a[2] / button")).Click(); Thread.Sleep(1500); LoginPage loginPage = new LoginPage(); loginPage.LoginStep(); loginPage.profileclick(); //Click on dropdown button Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[1]/i")).Click(); string FirstName = Driver.driver.FindElement(By.XPath(" / html / body / div[1] / div / section[2] / div / div / div / div[2] / div / div / div / div / div / div[2] / div / div / div[2] / div / div[1] / input[1]")).GetAttribute("value"); string LastName = Driver.driver.FindElement(By.XPath(" / html / body / div[1] / div / section[2] / div / div / div / div[2] / div / div / div / div / div / div[2] / div / div / div[2] / div / div[1] / input[2]")).GetAttribute("value"); string Language = Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/table/tbody[2]/tr/td[1]")).Text; string LanguageLevel = Driver.driver.FindElement(By.XPath("/ html / body / div[1] / div / section[2] / div / div / div / div[3] / form / div[2] / div / div[2] / div / table / tbody / tr / td[2]")).Text; if ((FirstName == "ViewTest") && (LastName == "CheckingView") && (Language == "Spain") && (LanguageLevel == "Basic")) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Profile Viewed Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Profile viewed successfully "); Assert.IsTrue(true); return; } }
public void UpdateAddedLanguage() { //for (int i = 1; i <= NumberOfLanguagesToAdd; i++) //{ //Reading language and updated language level from the excel String languageToUpdate = GlobalDefinitions.ExcelLib.ReadData(2, "LanguageToUpdate"); String languageLevelToUpdate = GlobalDefinitions.ExcelLib.ReadData(2, "LanguageLevelToUpdate"); //Searching through the Language list to find a language need to be updated for (int j = 1; j <= LanguageRecords.Count; j++) { String LanguageValue = GlobalDefinitions.driver.FindElement(By.XPath(LanguageBody + "[" + j + "]" + "//tr//td[1]")).Text; String LanguageLevelValue = GlobalDefinitions.driver.FindElement(By.XPath(LanguageBody + "[" + j + "]" + "//tr//td[2]")).Text; if (LanguageValue == (GlobalDefinitions.ExcelLib.ReadData(3, "Language")) && LanguageLevelValue == (GlobalDefinitions.ExcelLib.ReadData(3, "LanguageLevel"))) { GenericWait.ElementIsClickable(GlobalDefinitions.driver, "XPath", "//tbody" + "[" + j + "]//tr[1]//td[3]//span[1]//i[1]", 3); //Clicking edit button of the language needed to update GlobalDefinitions.driver.FindElement(By.XPath("//tbody" + "[" + j + "]//tr[1]//td[3]//span[1]//i[1]")).Click(); GenericWait.ElementIsVisible(GlobalDefinitions.driver, "Name", "level", 6); //Selecting the updated language level SelectElement chooseLanguageLevel = new SelectElement(LanguageLevelDropdown); chooseLanguageLevel.SelectByValue(languageLevelToUpdate); GenericWait.ElementIsClickable(GlobalDefinitions.driver, "XPath", "//input[contains(@value,'Update')]", 6); //Clicking Update button updateButtonLanguage.Click(); string img = SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Update Language"); break; } } }
public void ThenThatLanguageShouldBeDisplayedOnMyListing() { try { //Start the Reports CommonMethods.ExtentReports(); Thread.Sleep(1000); CommonMethods.test = CommonMethods.extent.StartTest("Add a Language"); Thread.Sleep(1000); // string ExpectedValue = "English"; //string ActualValue = Driver.driver.FindElement(By.XPath("//td[text()='English']")).Text; Thread.Sleep(500); var lang = new List <String> { "Hindi", "English", "Telugu" }; foreach (String l in lang) { if (l == "Hindi") { string ExpectedValue = "Hindi"; string ActualValue = Driver.driver.FindElement(By.XPath("//td[text()='Hindi']")).Text; if (ExpectedValue == ActualValue) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Added a Language Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageAdded"); } else { CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); } } if (l == "English") { string ExpectedValue = "English"; string ActualValue = Driver.driver.FindElement(By.XPath("//td[text()='English']")).Text; if (ExpectedValue == ActualValue) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Added a Language Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageAdded"); } else { CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); } } if (l == "Telugu") { string ExpectedValue = "Telugu"; string ActualValue = Driver.driver.FindElement(By.XPath("//td[text()='Telugu']")).Text; if (ExpectedValue == ActualValue) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Added a Language Successfully"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "LanguageAdded"); } else { CommonMethods.test.Log(LogStatus.Fail, "Test Failed"); } } } } catch (Exception e) { CommonMethods.test.Log(LogStatus.Fail, "Test Failed", e.Message); } }
public static void SaveScreenshot(String name) { SaveScreenShotClass.SaveScreenshot(Drivers.driver, name); }
internal void ValidateDaysAndTime() { try { IList <string> DaysList = GlobalDefinitions.ExcelLib.ReadData(2, "Selectday").Split('/'); //Getting count for all days //Check the checkbox is selected for days mentioned in excel and validate time for same int DaysRows = Days.FindElements(By.Name("Available")).Count; foreach (string AvailableDays in DaysList) { for (int i = 1; i <= DaysRows; i++) { string DayValue = Days.FindElements(By.ClassName("fields"))[i].Text; if (AvailableDays.ToLower() == DayValue.ToLower()) { Console.WriteLine("Selected {0}", Days.FindElements(By.Name("Available"))[i - 1].Selected); Console.WriteLine("First Start date check {0} {1}", Days.FindElements(By.Name("StartTime"))[i - 1].GetAttribute("value"), DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("HH:mm")); if (Days.FindElements(By.Name("Available"))[i - 1].Selected && Days.FindElements(By.Name("StartTime"))[i - 1].GetAttribute("value") == DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Starttime")).ToString("HH:mm") && Days.FindElements(By.Name("EndTime"))[i - 1].GetAttribute("value") == DateTime.Parse(GlobalDefinitions.ExcelLib.ReadData(2, "Endtime")).ToString("HH:mm")) { Base.test.Log(LogStatus.Pass, DayValue + " is selected and Time is Entered Successfully"); Assert.IsTrue(true); } else { Base.test.Log(LogStatus.Fail, DayValue + " is not selected or Time Entered Failed, Image - " + SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.driver, "Report")); } } } } } catch (Exception e) { Base.test.Log(LogStatus.Fail, "Caught Exception For Day and Time", e.Message); } }
// Update the given Skill public void UpdateSkill() { #region Update the given Skills Thread.Sleep(3000); // Populate Login page test data collection ExcelLib.PopulateInCollection(MarsResources.ExcelPath, "ProfileSkill"); String expectedValue = ExcelLib.ReadData(2, "Skill"); //Get the table list IList <IWebElement> Tablerows = driver.FindElements(By.XPath("//form/div[3]/div/div[2]/div/table/tbody/tr")); //Get the row count in table var rowCount = Tablerows.Count; for (int i = 1; i <= rowCount; i++) { //Get the xpath of ith row Skill name String actualValue = driver.FindElement(By.XPath("//div[3]/div/div[2]/div/table/tbody[" + i + "]/tr/td[1]")).Text; //check if the editLanguage Parameter matches with ith row Language name if (actualValue.Equals(expectedValue)) { //CliCk on Edit icon driver.FindElement(By.XPath("//div[3]/div/div[2]/div/table/tbody[" + i + "]/tr/td[3]/span[1]/i")).Click(); //Send Skill name to update IWebElement editRowValue = driver.FindElement(By.XPath("//div/table/tbody[" + i + "]/tr/td/div/div[1]/input")); //Clear Previous text editRowValue.Clear(); editRowValue.SendKeys(ExcelLib.ReadData(2, "UpdatedSkill")); //Select Skill Level to update var skillLevelList = driver.FindElement(By.XPath("//div/table/tbody[" + i + "]/tr/td/div/div[2]/select")); var selectElement = new SelectElement(skillLevelList); selectElement.SelectByIndex(1); // Click on update button driver.FindElement(By.XPath("//div/table/tbody[" + i + "]/tr/td/div/span/input[1]")).Click(); #endregion #region validate updated Skill try { //Start the Reports test = extent.CreateTest("Edit Skill"); test.Log(Status.Info, "Editing Skill"); String expectedValue1 = ExcelLib.ReadData(2, "UpdatedSkill"); //Get the table list IList <IWebElement> UpdatedTablerows = driver.FindElements(By.XPath("//form/div[2]/div/div[2]/div/table/tbody/tr")); //Get the row count in table var UpdatedrowCount1 = UpdatedTablerows.Count; for (var j = 1; j < UpdatedrowCount1; j++) { string actualValue1 = driver.FindElement(By.XPath("//div[3]/div/div[2]/div/table/tbody[" + i + "]/tr/td[1]")).Text; //Check if expected value is equal to actual value if (expectedValue1 == actualValue1) { test.Log(Status.Pass, "Skill updated Successful"); SaveScreenShotClass.SaveScreenshot(driver, "SkillLanguage"); Assert.IsTrue(true); } else { test.Log(Status.Fail, "Test Failed"); } } } catch (Exception e) { Console.WriteLine(e.Message); } Thread.Sleep(3000); } } #endregion }
public void AddAccount() { //Populate Excel Sheet Global.Definition.ExcelOperations.PopulateInCollection(Global.Definition.ReadJson().ExcelPath, "SignIn"); Thread.Sleep(500); //Enter URL Definition.driver.Navigate().GoToUrl(Definition.ExcelOperations.ReadData(1, "URL")); Thread.Sleep(500); //Click on SignUp Button //signInbtn.Click(); Thread.Sleep(500); //Enter Email Address email.Clear(); email.SendKeys(Definition.ExcelOperations.ReadData(1, "Email")); Thread.Sleep(500); //Enter Password password.SendKeys(Definition.ExcelOperations.ReadData(1, "Password")); Thread.Sleep(500); //Click on submit button join.Click(); Thread.Sleep(500); //Click on link for creating ANZ account Link.Click(); Thread.Sleep(1000); //Search for ANZ bank Search.SendKeys("ANZ"); Thread.Sleep(200); //Click on the ANZ option searchItem.Click(); //Enter Account Name AccountName.SendKeys("William Jack"); //Select Account Type -> first open the drop down and select the option AccountType.Click(); SelectAccountType.Click(); //Enter Account Number cardnumber.SendKeys("4356384752894"); //Click Continue to Exit Continue.Click(); //Capture ScreenShot SaveScreenShotClass.SaveScreenshot(Definition.driver, "Home Page"); Thread.Sleep(2000); //Verification Code string Expected_Message = Verification.Text; string Actual_Message = "Let your bank send transactions to Xero"; try { if (Expected_Message == Actual_Message) { Console.WriteLine("Thank you for creating account at Xero"); //Capture ScreenShot SaveScreenShotClass.SaveScreenshot(Definition.driver, "Account Created Successfully"); Thread.Sleep(1000); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public void Description() { Initialize(); Thread.Sleep(500); //Call the Login Class LoginPage loginPage = new LoginPage(); loginPage.LoginStep(); loginPage.profileclick(); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[1]/i")).Click(); //Add First Name Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div[1]/input[1]")).Clear(); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div[1]/input[1]")).SendKeys("Jijitha"); //Add Last Name Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div[1]/input[2]")).Clear(); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div[1]/input[2]")).SendKeys("Anand"); //Click on Save Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[2]/div/div/div[2]/div/div[2]/button")).Click(); //Click on Add New button Thread.Sleep(1500); waitVisiblity(driver, "XPath", "/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/table/thead/tr/th[3]/div"); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/table/thead/tr/th[3]/div")).Click(); //Add Language // waitVisiblity(driver, "XPath", "/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/div/div[1]/input"); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/div/div[1]/input")).SendKeys("English"); //Click on Language Level Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/div/div[2]/select")).Click(); //Choose the language level IWebElement Lang = Driver.driver.FindElements(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/div/div[2]/select/option"))[1]; Lang.Click(); //Click on Add button Driver.driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/div/div[3]/input[1]")).Click(); //Click description Thread.Sleep(1500); //Driver.waitVisiblity(driver, "XPath", "/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/div/h3/span"); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/div/h3/span")).Click(); //Add description //Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/form/div/div/div[2]/div[1]/textarea")).Text; Thread.Sleep(1500); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/form/div/div/div[2]/div[1]/textarea")).Clear(); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/form/div/div/div[2]/div[1]/textarea")).SendKeys("Hi, have experience with eWam, which uses Gold language"); //Click save Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/form/div/div/div[2]/button")).Click(); //click on share skill Thread.Sleep(1500); Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[1]/div/div[2]/a")).Click(); //wait Driver.waitVisiblity(Driver.driver, "XPath", "/html/body/div/div/div[1]/div[2]/div/form/div[1]/div/div[2]/div/div[1]/input"); //Add Title Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[1]/div/div[2]/div/div[1]/input")).SendKeys("eWam"); //Add Description Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[2]/div/div[2]/div[1]/textarea")).SendKeys("Automation and Manual Testing Enginner"); //Click dropdown Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[3]/div[2]/div/div/select")).Click(); //Select category Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[3]/div[2]/div/div[1]/select/option[7]")).Click(); //Click dropdown Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[3]/div[2]/div/div[2]/div[1]/select")).Click(); //Select Sub-category Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[3]/div[2]/div/div[2]/div[1]/select/option[5]")).Click(); //Tag Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[4]/div[2]/div/div/div/div/input")).SendKeys("Manual"); Driver.driver.FindElement(By.XPath("/ html / body / div / div / div[1] / div[2] / div / form / div[4] / div[2] / div / div / div / div / input")).SendKeys(Keys.Enter); //Service type Driver.driver.FindElement(By.XPath("/ html / body / div / div / div[1] / div[2] / div / form / div[5] / div[2] / div[1] / div[1] / div / input")).Click(); //Location Type Driver.driver.FindElement(By.XPath("/ html / body / div / div / div[1] / div[2] / div / form / div[6] / div[2] / div / div[2] / div / input")).Click(); //Avaliable days Driver.driver.FindElement(By.XPath("/ html / body / div / div / div[1] / div[2] / div / form / div[7] / div[2] / div / div[3] / div[1] / div / input")).Click(); Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div/div[4]/div[1]/div/input")).Click(); Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[7]/div[2]/div/div[5]/div[1]/div/input")).Click(); //Skill Trade Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[8]/div[2]/div/div[1]/div/input")).Click(); //Skill Exchange Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[8]/div[4]/div/div/div/div/div/input")).SendKeys("ManualTesting"); Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[8]/div[4]/div/div/div/div/div/input")).SendKeys(Keys.Enter); //Active Driver.driver.FindElement(By.XPath("/ html / body / div / div / div[1] / div[2] / div / form / div[10] / div[2] / div / div[1] / div / input")).Click(); //Save Driver.driver.FindElement(By.XPath("/html/body/div/div/div[1]/div[2]/div/form/div[11]/div/input[1]")).Click(); //log out Driver.driver.FindElement(By.XPath("/html/body/div/div/div/div[1]/div[2]/div/a[2]/button")).Click(); Driver.Close(); //login again //Launch the browser Initialize(); Thread.Sleep(500); Driver.NavigateUrl(); //Enter Url Driver.driver.FindElement(By.XPath("//*[@id=\"home\"]/div/div/div[1]/div/a")).Click(); //Enter Username Driver.driver.FindElement(By.XPath("/html/body/div[2]/div/div/div[1]/div/div[1]/input")).SendKeys("*****@*****.**"); //Enter password Driver.driver.FindElement(By.XPath("/html/body/div[2]/div/div/div[1]/div/div[2]/input")).SendKeys("123456"); Thread.Sleep(1000); //Click on Login Button Driver.driver.FindElement(By.XPath("/html/body/div[2]/div/div/div[1]/div/div[4]/button")).Click(); Thread.Sleep(1500); //Enter Search skill Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/div[1]/div[1]/input")).SendKeys("eWam"); //click on search button Driver.driver.FindElement(By.XPath("/ html / body / div[1] / div / div[1] / div[1] / i")).Click(); while (true) { for (var j = 2; j <= 100; j++) { for (var i = 1; i <= 9; i++) { IWebElement Name = driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div/section/div/div[2]/div/div[2]/div/div/div[" + i + "]/div[1]/a[1]")); IWebElement Title = driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div/section/div/div[2]/div/div[2]/div/div/div[" + i + "]/div[1]/a[2]/p")); Thread.Sleep(500); if (Name.Text == "Jijitha Anand" && Title.Text == "eWam") { //Click on Skill Driver.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div/section/div/div[2]/div/div[2]/div/div/div/a/img")).Click(); //Click on Profile Driver.driver.FindElement(By.XPath("/html/body/div[1]/div[2]/div/div[2]/div[2]/div[1]/div/div[1]/a/i")).Click(); Thread.Sleep(1500); string Description = Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/div/div/div/span")).Text; //Click on Language Tab Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[1]/a[2]")).Click(); string Language = Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[3]/table/tbody/tr/td[1]")).Text; string LanguageLevel = Driver.driver.FindElement(By.XPath("/html/body/div[1]/div/section[2]/div/div/div/div[3]/form/div[3]/table/tbody/tr/td[2]")).Text; if ((Description == "Hi, have experience with eWam, which uses Gold language") && (Language == "English") && (LanguageLevel == "Basic")) { CommonMethods.test.Log(LogStatus.Pass, "Test Passed, Profile Viewed Successfully with specific skill"); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Profile viewed successfully with specific skill "); Assert.IsTrue(true); } } } Driver.driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div/section/div/div[2]/div/div[3]/div[2]/div/button[" + j + "]")).Click(); } } }
// Advanced search public void Advancedsearch() { try { ExcelLib.PopulateInCollection(Base.ExcelPath, "Advanced search"); // Properties for rent link Driver.ActionButton(Driver.driver, ExcelLib.ReadData(2, "Locator"), ExcelLib.ReadData(2, "Value")); Thread.Sleep(500); //Advanced search Driver.ActionButton(Driver.driver, ExcelLib.ReadData(11, "Locator"), ExcelLib.ReadData(11, "Value")); Thread.Sleep(500); //Advanced search Driver.ActionButton(Driver.driver, ExcelLib.ReadData(3, "Locator"), ExcelLib.ReadData(3, "Value")); Thread.Sleep(500); //Select Region from the list IList<IWebElement> Regions = Driver.driver.FindElements(By.XPath("//*[@id='Address_Region']/option[13]")); int RegionCount = Regions.Count(); for (int i = 0; i < RegionCount; i++) { if (Regions[i].Text == "Canterbury") { Thread.Sleep(500); Regions[i].Click(); } } //Select District from the list IList<IWebElement> Districts = Driver.driver.FindElements(By.XPath("//*[@id='Address_City']/option[3]")); int Districtscount = Districts.Count(); for (int i = 0; i < Districtscount; i++) { if (Districts[i].Text == "Christchurch City") { Thread.Sleep(500); Districts[i].Click(); } } //Select Suburbs from the list IList<IWebElement> Suburbs = Driver.driver.FindElements(By.XPath("//*[@id='Address_SuburbList']/option[46]")); int Suburbscount = Suburbs.Count(); for (int i = 0; i < Suburbscount; i++) { if (Suburbs[i].Text == "Linwood") { Thread.Sleep(500); Suburbs[i].Click(); } } //Select Bedrooms from the list IList<IWebElement> Bedrooms = Driver.driver.FindElements(By.XPath("//*[@id='BedroomMin']/option[3]")); int Bedroomscount = Bedrooms.Count(); for (int i = 0; i < Bedroomscount; i++) { if (Bedrooms[i].Text == "2") { Thread.Sleep(500); Bedrooms[i].Click(); } } //Select Bedrooms from the list IList<IWebElement> Bedrooms1 = Driver.driver.FindElements(By.XPath("//*[@id='BedroomMax']/option[4]")); int Bedroomscount1 = Bedrooms1.Count(); for (int i = 0; i < Bedroomscount1; i++) { if (Bedrooms1[i].Text == "3") { Thread.Sleep(500); Bedrooms1[i].Click(); } } //Select Bathrooms from the list IList<IWebElement> Bathrooms = Driver.driver.FindElements(By.XPath("//*[@id='BathroomMin']/option[2]")); int Bathroomscount = Bathrooms.Count(); for (int i = 0; i < Bathroomscount; i++) { if (Bathrooms[i].Text == "1") { Thread.Sleep(500); Bathrooms[i].Click(); } } //Select Bathrooms from the list IList<IWebElement> Bathrooms1 = Driver.driver.FindElements(By.XPath("//*[@id='BathroomMax']/option[3]")); int Bathroomscount1 = Bathrooms1.Count(); for (int i = 0; i < Bathroomscount1; i++) { if (Bathrooms1[i].Text == "2") { Thread.Sleep(500); Bathrooms1[i].Click(); } } //Rent per week Driver.Textbox(Driver.driver, ExcelLib.ReadData(4, "Locator"), ExcelLib.ReadData(4, "Value"), ExcelLib.ReadData(RowCountBase, "Rentmin")); Thread.Sleep(2000); Driver.Textbox(Driver.driver, ExcelLib.ReadData(5, "Locator"), ExcelLib.ReadData(5, "Value"), ExcelLib.ReadData(RowCountBase, "Rentmax")); Thread.Sleep(2000); //proprty ID Driver.Textbox(Driver.driver, ExcelLib.ReadData(6, "Locator"), ExcelLib.ReadData(6, "Value"), ExcelLib.ReadData(RowCountBase, "PropID")); Thread.Sleep(2000); //Select Proptype from the list IList<IWebElement> Proptype = Driver.driver.FindElements(By.XPath("//*[@id='advanced-search']/fieldset[4]/div/span/div/button/span/option[2]")); int Proptypecount = Proptype.Count(); for (int i = 0; i < Proptypecount; i++) { if (Proptype[i].Text == "Affordable Housing") { Thread.Sleep(500); Proptype[i].Click(); } } //Select Landarea from the list IList<IWebElement> Landarea = Driver.driver.FindElements(By.XPath("//*[@id='LandSqmMin']/option[2]")); int Landareacount = Landarea.Count(); for (int i = 0; i < Landareacount; i++) { if (Landarea[i].Text == "400") { Thread.Sleep(500); Landarea[i].Click(); } } //Select Landarea from the list IList<IWebElement> Landarea1 = Driver.driver.FindElements(By.XPath("//*[@id='LandSqmMax']/option[4]")); int Landareacount1 = Landarea1.Count(); for (int i = 0; i < Landareacount1; i++) { if (Landarea1[i].Text == "1200") { Thread.Sleep(500); Landarea1[i].Click(); } } //Click on Search Driver.ActionButton(Driver.driver, ExcelLib.ReadData(7, "Locator"), ExcelLib.ReadData(7, "Value")); Thread.Sleep(2000); try { IList proplistt = Driver.driver.FindElements(By.XPath(ExcelLib.ReadData(63, "Value"))); int listcountS = proplistt.Count; for (int i = 1; i <= listcountS; i++) { if (ExcelLib.ReadData(2, "Name") == Driver.GetTextValue(Driver.driver, ExcelLib.ReadData(61, "Locator"), ExcelLib.ReadData(61, "Value") + i + ExcelLib.ReadData(61, "Value2"))) { SaveScreenShotClass.SaveScreenshot(Driver.driver, "Searched Property is found"); Thread.Sleep(2000); //Log Info Base.test.Log(LogStatus.Pass, "Searched Property found and verified"); Thread.Sleep(2000); break; } else { Base.test.Log(LogStatus.Fail, "Property not found, search property test failed"); } } } catch (Exception e) { Base.test.Log(LogStatus.Info, e.Message + "There is an issue,Please check"); } } catch (Exception e) { Base.test.Log(LogStatus.Error, e.Message + "Error : "); } }
internal void ClickView() { GlobalDefinitions.ExcelLib.PopulateInCollection(@"C:\Users\JIJI\source\repos\marsframework-master\MarsFramework\ExcelData\TestDataManageListings.xlsx", "ViewSkill"); Global.Base bases = new Global.Base(); Global.Base.ExtentReports(); Thread.Sleep(1000); Global.Base.test = Global.Base.extent.StartTest("View skill"); int counts = 0; counts = Global.GlobalDefinitions.Driver.FindElements(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr")).Count; check = 0; if (counts != 0) { if (counts == 1) { Thread.Sleep(1000); IWebElement Category = Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr/td[2]")); IWebElement Title = Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr/td[3]")); IWebElement Description = Global.GlobalDefinitions.Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr/td[4]")); if (Title.Text == GlobalDefinitions.ExcelLib.ReadData(2, "Title") && Description.Text == ExcelLib.ReadData(2, "Description")) { check++; if (check != 0) { view.Click(); viewListing(); } } return; } else { for (var i = 1; i <= counts; i++) { Thread.Sleep(1000); IWebElement Category = Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[2]")); IWebElement Title = Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[3]")); IWebElement Description = Global.GlobalDefinitions.Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[4]")); if (Title.Text == GlobalDefinitions.ExcelLib.ReadData(2, "Title") && Description.Text == ExcelLib.ReadData(2, "Description")) { check++; if (check != 0) { Driver.FindElement(By.XPath("/html/body/div/div/div/div[2]/div[1]/div[1]/table/tbody/tr[" + i + "]/td[8]/div/button[1]/i")).Click(); viewListing(); } return; } } } if (check == 0) { check = 1; Global.Base.test.Log(LogStatus.Pass, "Test Passed, Conserened Skill not found"); SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.Driver, "Conserned Skill not found"); Assert.AreEqual(check, 0); return; } } else { Global.Base.test.Log(LogStatus.Pass, "Test passed, Skill List is Empty for view"); SaveScreenShotClass.SaveScreenshot(GlobalDefinitions.Driver, "List in Manage Listing is Empty to view"); Assert.AreEqual(counts, 0); } }
// Add new property public void AddnewProperty() { try { ExcelLib.PopulateInCollection(Base.ExcelPath, "AddNewProperty"); // Owner link Driver.ActionButton(Driver.driver, ExcelLib.ReadData(2, "Locator"), ExcelLib.ReadData(2, "Value")); Thread.Sleep(500); //properties option Driver.ActionButton(Driver.driver, ExcelLib.ReadData(3, "Locator"), ExcelLib.ReadData(3, "Value")); Thread.Sleep(1000); //AddNewProperty Driver.ActionButton(Driver.driver, ExcelLib.ReadData(4, "Locator"), ExcelLib.ReadData(4, "Value")); Thread.Sleep(1000); //Read data from excel sheet to fill the Property deatils //Property Name Driver.Textbox(Driver.driver, ExcelLib.ReadData(5, "Locator"), ExcelLib.ReadData(5, "Value"), ExcelLib.ReadData(RowCountBase, "Name")); Thread.Sleep(1000); //Description Driver.Textbox(Driver.driver, ExcelLib.ReadData(6, "Locator"), ExcelLib.ReadData(6, "Value"), ExcelLib.ReadData(RowCountBase, "Desc")); Thread.Sleep(1000); //PropertyType Driver.Textbox(Driver.driver, ExcelLib.ReadData(7, "Locator"), ExcelLib.ReadData(7, "Value"), ExcelLib.ReadData(RowCountBase, "PropertyType")); Thread.Sleep(1000); //Choose Property Type from Dropdown list IList<IWebElement> proptypelist = Driver.driver.FindElements(By.XPath("//*[@id='property-details']/div[1]/div[2]/div/div/div/ul/li")); int listcount = proptypelist.Count(); for (int i = 0; i < listcount; i++) { if (proptypelist[i].Text == "Student Housing") { proptypelist[i].Click(); } } //Search Address Driver.Textbox(Driver.driver, ExcelLib.ReadData(10, "Locator"), ExcelLib.ReadData(10, "Value"), ExcelLib.ReadData(RowCountBase, "Address")); Thread.Sleep(2000); new Actions(Driver.driver).SendKeys(OpenQA.Selenium.Keys.ArrowDown).Perform(); Thread.Sleep(2000); new Actions(Driver.driver).SendKeys(OpenQA.Selenium.Keys.Return).Perform(); Thread.Sleep(2000); //scroll down IJavaScriptExecutor jse = (IJavaScriptExecutor)Driver.driver; IWebElement element1 = Driver.driver.FindElement(By.XPath(ExcelLib.ReadData(25, "Value"))); (jse).ExecuteScript("arguments[0].scrollIntoView(true);", element1); Thread.Sleep(1000); //Select rent type from the drop down IList<IWebElement> Renttypes = Driver.driver.FindElements(By.XPath("//*[@id='property-details']/div[3]/div[3]/div/select/option")); int RentTypeCount = Renttypes.Count(); for (int i = 0; i < RentTypeCount; i++) { if (Renttypes[i].Text == "Monthly") { Thread.Sleep(2000); Renttypes[i].Click(); } } //Year Built Driver.Textbox(Driver.driver, ExcelLib.ReadData(21, "Locator"), ExcelLib.ReadData(21, "Value"), ExcelLib.ReadData(RowCountBase, "Year")); Thread.Sleep(1000); //target rent Driver.Textbox(Driver.driver, ExcelLib.ReadData(32, "Locator"), ExcelLib.ReadData(32, "Value"), ExcelLib.ReadData(RowCountBase, "TargetRent")); Thread.Sleep(1000); //Bedrooms Driver.Textbox(Driver.driver, ExcelLib.ReadData(23, "Locator"), ExcelLib.ReadData(23, "Value"), ExcelLib.ReadData(RowCountBase, "Bedroom")); Thread.Sleep(2000); //Bathrooms Driver.Textbox(Driver.driver, ExcelLib.ReadData(25, "Locator"), ExcelLib.ReadData(25, "Value"), ExcelLib.ReadData(RowCountBase, "Bathroom")); Thread.Sleep(2000); //FloorArea Driver.Textbox(Driver.driver, ExcelLib.ReadData(27, "Locator"), ExcelLib.ReadData(27, "Value"), ExcelLib.ReadData(RowCountBase, "FloorArea")); Thread.Sleep(2000); //Land Area Driver.Textbox(Driver.driver, ExcelLib.ReadData(29, "Locator"), ExcelLib.ReadData(29, "Value"), ExcelLib.ReadData(RowCountBase, "LandArea")); Thread.Sleep(2000); //Car parks Driver.Textbox(Driver.driver, ExcelLib.ReadData(31, "Locator"), ExcelLib.ReadData(31, "Value"), ExcelLib.ReadData(RowCountBase, "Carparks")); Thread.Sleep(2000); //scroll down IJavaScriptExecutor js1 = (IJavaScriptExecutor)Driver.driver; IWebElement element2 = Driver.driver.FindElement(By.XPath(ExcelLib.ReadData(34, "Value"))); (js1).ExecuteScript("arguments[0].scrollIntoView(true);", element2); //Next button not enabled dynamically - include action tab key new Actions(Driver.driver).SendKeys(OpenQA.Selenium.Keys.Tab).Perform(); Thread.Sleep(2000); //click on next Driver.ActionButton(Driver.driver, ExcelLib.ReadData(34, "Locator"), ExcelLib.ReadData(34, "Value")); Thread.Sleep(3000); } catch (Exception e) { Base.test.Log(LogStatus.Info, e.Message + "There is an issue,Please check"); } try { //Add financial data //purchase price Driver.Textbox(Driver.driver, ExcelLib.ReadData(37, "Locator"), ExcelLib.ReadData(37, "Value"), ExcelLib.ReadData(37, "Value2")); Thread.Sleep(2000); //Mortgage Driver.Textbox(Driver.driver, ExcelLib.ReadData(38, "Locator"), ExcelLib.ReadData(38, "Value"), ExcelLib.ReadData(38, "Value2")); Thread.Sleep(2000); //Home Value Driver.Textbox(Driver.driver, ExcelLib.ReadData(39, "Locator"), ExcelLib.ReadData(39, "Value"), ExcelLib.ReadData(39, "Value2")); Thread.Sleep(2000); //Select home value type from the dropdown IList<IWebElement> homevaluetypes = Driver.driver.FindElements(By.XPath("//*[@id='financeSection']/div[2]/div[2]/div/select/option")); int HomevalueTypeCount = homevaluetypes.Count(); for (int i = 0; i < HomevalueTypeCount; i++) { if (homevaluetypes[i].Text == "Estimated") { Thread.Sleep(2000); homevaluetypes[i].Click(); } } Thread.Sleep(2000); IJavaScriptExecutor js = (IJavaScriptExecutor)Driver.driver; Thread.Sleep(2000); IWebElement element = Driver.driver.FindElement(By.XPath(ExcelLib.ReadData(56, "Value"))); (js).ExecuteScript("arguments[0].scrollIntoView(true);", element); Thread.Sleep(2000); //Click on next Driver.ActionButton(Driver.driver, ExcelLib.ReadData(56, "Locator"), ExcelLib.ReadData(56, "Value")); Thread.Sleep(1000); } catch (Exception e) { Base.test.Log(LogStatus.Info, e.Message + "There is an issue,Please check"); } try { //Add tenant details //Enter tenant email Driver.Textbox(Driver.driver, ExcelLib.ReadData(50, "Locator"), ExcelLib.ReadData(50, "Value"), ExcelLib.ReadData(50, "Value2")); Thread.Sleep(2000); //Main tenant IList<IWebElement> maintenant = Driver.driver.FindElements(By.XPath("//*[@id='tenant-area']/div[1]/div[2]/div/select/option")); int mainCount = maintenant.Count(); for (int i = 0; i < mainCount; i++) { if (maintenant[i].Text == "No") { Thread.Sleep(2000); maintenant[i].Click(); } } //First Name Thread.Sleep(2000); Driver.Textbox(Driver.driver, ExcelLib.ReadData(65, "Locator"), ExcelLib.ReadData(65, "Value"), ExcelLib.ReadData(65, "Value2")); //Last Name Thread.Sleep(2000); Driver.Textbox(Driver.driver, ExcelLib.ReadData(66, "Locator"), ExcelLib.ReadData(66, "Value"), ExcelLib.ReadData(66, "Value2")); //Start Date Thread.Sleep(2000); Driver.GetClear(Driver.driver, ExcelLib.ReadData(51, "Locator"), ExcelLib.ReadData(51, "Value")); Thread.Sleep(1000); Driver.Textbox(Driver.driver, ExcelLib.ReadData(51, "Locator"), ExcelLib.ReadData(51, "Value"), ExcelLib.ReadData(51, "Value2")); //End Date Thread.Sleep(3000); Driver.GetClear(Driver.driver, ExcelLib.ReadData(52, "Locator"), ExcelLib.ReadData(52, "Value")); Thread.Sleep(1000); Driver.Textbox(Driver.driver, ExcelLib.ReadData(52, "Locator"), ExcelLib.ReadData(52, "Value"), ExcelLib.ReadData(52, "Value2")); //Payment Frequency IList<IWebElement> payfreqlist = Driver.driver.FindElements(By.XPath("//*[@id='tenantSection']/div[4]/div[2]/div/select/option")); int payfreqCount = payfreqlist.Count(); for (int i = 0; i < payfreqCount; i++) { if (payfreqlist[i].Text == "Monthly") { Thread.Sleep(2000); payfreqlist[i].Click(); } } //Enter rent amount Driver.Textbox(Driver.driver, ExcelLib.ReadData(58, "Locator"), ExcelLib.ReadData(58, "Value"), ExcelLib.ReadData(58, "Value2")); Thread.Sleep(2000); //payment start date Thread.Sleep(3000); Driver.GetClear(Driver.driver, ExcelLib.ReadData(67, "Locator"), ExcelLib.ReadData(67, "Value")); Thread.Sleep(1000); Driver.Textbox(Driver.driver, ExcelLib.ReadData(67, "Locator"), ExcelLib.ReadData(67, "Value"), ExcelLib.ReadData(67, "Value2")); //payment due date Thread.Sleep(1000); IList<IWebElement> payduelist = Driver.driver.FindElements(By.XPath("//*[@id='tenantSection']/div[5]/div[2]/div/select/option")); int paydueCount = payduelist.Count(); for (int i = 0; i < paydueCount; i++) { if (payduelist[i].Text == "1") { payduelist[i].Click(); } } Thread.Sleep(2000); IWebElement save = Driver.driver.FindElement(By.XPath(ExcelLib.ReadData(54, "Value"))); if (save.Enabled) { Driver.ActionButton(Driver.driver, ExcelLib.ReadData(54, "Locator"), ExcelLib.ReadData(54, "Value")); Thread.Sleep(1000); Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Mandatory fields entered, Clicked on save button to add a new property"); Thread.Sleep(1000); //Check if unregistered tenant alert on screen, if so accept if (Driver.isDialogPresent(Driver.driver)) { Driver.driver.SwitchTo().Alert().Accept(); } Thread.Sleep(1000); Base.test.Log(LogStatus.Info, "Record added sucessfully"); Thread.Sleep(3000); //verify added record and navigate through pages to find the record Driver.Textbox(Driver.driver, ExcelLib.ReadData(43, "Locator"), ExcelLib.ReadData(43, "Value"), ExcelLib.ReadData(RowCountBase, "Name")); Thread.Sleep(2000); //SearchButton.Click(); Driver.ActionButton(Driver.driver, ExcelLib.ReadData(44, "Locator"), ExcelLib.ReadData(44, "Value")); Thread.Sleep(2000); //If property search returns no results popup occurs and test failed if (Driver.ElementVisible(Driver.driver, ExcelLib.ReadData(64, "Locator"), ExcelLib.ReadData(64, "Value")) == true) { Base.test.Log(LogStatus.Fail, "Search for Property found no results, add property test failed"); } /* //get row count using Ilist IList proplistt = Driver.driver.FindElements(By.XPath(ExcelLib.ReadData(63, "Value"))); int listcountS = proplistt.Count; for (int i = 1; i <= listcountS; i++) { if (ExcelLib.ReadData(2, "Name") == Driver.GetTextValue(Driver.driver, ExcelLib.ReadData(61, "Locator"), ExcelLib.ReadData(61, "Value") + i + ExcelLib.ReadData(61, "Value2"))) {*/ IWebElement Name = Driver.driver.FindElement(By.XPath("//*[@id='mainPage']/div[4]/div[1]/div/div/div[2]/div[2]/div[1]/div[1]/div[1]")); string confirmName = Name.Text; Assert.AreEqual("Spencors villa", confirmName); IWebElement Address = Driver.driver.FindElement(By.XPath("//*[@id='mainPage']/div[4]/div[1]/div/div/div[2]/div[2]/div[1]/div[1]/div[2]/span[1]")); string confirmAddress = Address.Text; Assert.AreEqual("411 Gloucester Street,", confirmAddress); IWebElement Address1 = Driver.driver.FindElement(By.XPath("//*[@id='mainPage']/div[4]/div[1]/div/div/div[2]/div[2]/div[1]/div[1]/div[2]/span[2]")); string confirmAddress1 = Address1.Text; Assert.AreEqual("Linwood, Christchurch", confirmAddress1); IWebElement PurchasePrice = Driver.driver.FindElement(By.XPath("//*[@id='mainPage']/div[4]/div[1]/div/div/div[2]/div[2]/div[1]/div[2]/div[1]/span")); string confirmPrice = PurchasePrice.Text; Assert.AreEqual("1,200,000.00", confirmPrice); IWebElement Homevalue = Driver.driver.FindElement(By.XPath("//*[@id='mainPage']/div[4]/div[1]/div/div/div[2]/div[2]/div[1]/div[2]/div[2]/span")); string confirmHomevalue = Homevalue.Text; Assert.AreEqual("1,500,000.00", confirmHomevalue); SaveScreenShotClass.SaveScreenshot(Driver.driver, "Found Added Property"); Thread.Sleep(2000); //Log Info Base.test.Log(LogStatus.Pass, "Added Property found and verified"); Thread.Sleep(2000); /* break; } else { Base.test.Log(LogStatus.Fail, "Property not found, add property test failed"); } }*/ } else { Base.test.Log(RelevantCodes.ExtentReports.LogStatus.Info, "Submit button is disabled. Please check your data"); } } catch (Exception e) { Base.test.Log(LogStatus.Error, e.Message + "Error : "); }