public void EditTM(IWebDriver driver) { // wait //Thread.Sleep(1000); // wait for the TM page to be loaded and Edit button rendered Sync.WaitForVisiblitity(driver, "XPath", ".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[5]/a[1]", 10); // click on edit button driver.FindElement(By.XPath(".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[5]/a[1]")).Click(); // remove record from code button driver.FindElement(By.XPath("//*[@id='Code']")).Clear(); // Populate Edit TM test data collection ExcelLibHelpers.PopulateInCollection(@"A:\TestCases\Login Page\Login Page\TestData\TestData.xls", "TMPage"); // Fill the value in code button driver.FindElement(By.XPath("//*[@id='Code']")).SendKeys(ExcelLibHelpers.ReadData(3, "Code")); // remove record from description box driver.FindElement(By.XPath("//*[@id='Description']")).Clear(); // identify description button driver.FindElement(By.XPath("//*[@id='Description']")).SendKeys(ExcelLibHelpers.ReadData(3, "Description")); // click on save button driver.FindElement(By.XPath("//*[@id='SaveButton']")).Click(); // Wait //Thread.Sleep(2000); // wait for the TM page to be loaded and Edited Code textbox button rendered Sync.WaitForVisiblitity(driver, "XPath", "//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]", 10); // Implementation of Assertion Assert.That(driver.FindElement(By.XPath("//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]")).Text, Is.EqualTo(ExcelLibHelpers.ReadData(3, "Code"))); // verify if T&M editing is success //if (driver.FindElement(By.XPath("//*[@id='tmsGrid']/div[3]/table/tbody/tr[1]/td[1]")).Text == "Industry1") //{ // Console.WriteLine("T&M edited successfully, Test Passed"); //} //else //{ // Console.WriteLine("Test Failed"); //} }
public void VerifyDeleteProfile() { //Populate data saved in Excel ExcelLibHelpers.PopulateInCollection(Paths.ExcelPath, "Profile"); //Refresh the page driver.Navigate().Refresh(); //Wait for all text present in Element WaitHelpers.WaitForTextPresentInElement(driver, profileName, ExcelLibHelpers.ReadData(3, "Column18"), 10); #region Verify Delete Language //Jump to Language tab LanguageTab.Click(); //Read data saved in Excel var languageExcel = ExcelLibHelpers.ReadData(3, "Column1"); try { //Find the last row data driver.FindElement(By.XPath("//div[@data-tab='first']" + "//table/tbody[last()]/tr//*[contains(text(), '" + languageExcel + "')]")); Assert.Fail("Failed to delete language"); } catch (NoSuchElementException) { } #endregion #region Verify Delete Skills //Jump to Skill tab SkillTab.Click(); //Read Skill saved in Excel var skillExcel = ExcelLibHelpers.ReadData(3, "Column3"); try { //Check the last row data driver.FindElement(By.XPath("//div[@data-tab='second']" + "//table/tbody[last()]/tr//*[contains(text(), '" + skillExcel + "')]")); Assert.Fail("Failed to delete skill"); } catch (NoSuchElementException) { } #endregion #region Verify Delete Education //Jump to Education tab EducationTab.Click(); //Read Education info saved in excel var instituteNameExcel = ExcelLibHelpers.ReadData(3, "Column6"); var instituteCountryExcel = ExcelLibHelpers.ReadData(3, "Column7"); var instituteTitleExcel = ExcelLibHelpers.ReadData(3, "Column8"); var instituteDegreeExcel = ExcelLibHelpers.ReadData(3, "Column9"); var instituteGraduateYearExcel = ExcelLibHelpers.ReadData(3, "Column10"); try { //Find the last row data driver.FindElement(By.XPath("//div[@data-tab='third']" + "//table/tbody[last()]/tr//*[contains(text(), '" + instituteCountryExcel + "')]")); driver.FindElement(By.XPath("//div[@data-tab='third']" + "//table/tbody[last()]/tr//*[contains(text(), '" + instituteTitleExcel + "')]")); driver.FindElement(By.XPath("//div[@data-tab='third']" + "//table/tbody[last()]/tr//*[contains(text(), '" + instituteDegreeExcel + "')]")); driver.FindElement(By.XPath("//div[@data-tab='third']" + "//table/tbody[last()]/tr//*[contains(text(), '" + instituteGraduateYearExcel + "')]")); driver.FindElement(By.XPath("//div[@data-tab='third']" + "//table/tbody[last()]/tr//*[contains(text(), '" + instituteNameExcel + "')]")); Assert.Fail("Failed to delete education."); } catch (NoSuchElementException) { } #endregion #region Verify Delete Certificate //Jump to Certification tab CertificationTab.Click(); //Read Education info saved in excel var certificateNameExcel = ExcelLibHelpers.ReadData(3, "Column12"); var certificateFromExcel = ExcelLibHelpers.ReadData(3, "Column13"); var certificateYearExcel = ExcelLibHelpers.ReadData(3, "Column14"); try { //Find the last row data driver.FindElement(By.XPath("//div[@data-tab='fourth']" + "//table/tbody[last()]/tr//*[contains(text(), '" + certificateNameExcel + "')]")); driver.FindElement(By.XPath("//div[@data-tab='fourth']" + "//table/tbody[last()]/tr//*[contains(text(), '" + certificateFromExcel + "')]")); driver.FindElement(By.XPath("//div[@data-tab='fourth']" + "//table/tbody[last()]/tr//*[contains(text(), '" + certificateYearExcel + "')]")); Assert.Fail("Failed to delete certificate."); } catch (NoSuchElementException) { } #endregion }
internal void details() { driver.FindElement(By.XPath("//a[@href='#'][contains(.,'Administration')]")).Click(); driver.FindElement(By.XPath("//a[@href='/TimeMaterial']")).Click(); driver.FindElement(By.XPath("//a[@href='/TimeMaterial/Create']")).Click(); Thread.Sleep(3000); //Drop Down // SelectElement s = new SelectElement(driver.FindElement(By.XPath("(//span[@unselectable='on'])[3]"))); // s.SelectByText("Time"); //ExcelData Reader ExcelLibHelpers.PopulateInCollection(@"C:\Users\Owner\source\repos\Firstautomation\Firstautomation\TestData\TestData.xls", "Mysheet"); sun.SendKeys(ExcelLibHelpers.ReadData(2, "Code")); driver.FindElement(By.XPath("//input[@id='Description']")).SendKeys(ExcelLibHelpers.ReadData(2, "Description")); driver.FindElement(By.XPath("//input[contains(@class,'k-formatted-value k-input')]")).SendKeys(ExcelLibHelpers.ReadData(2, "Price")); Thread.Sleep(3000); driver.FindElement(By.XPath("//*[@id=\"SaveButton\"]")).Click(); }
public void AddTM(IWebDriver driver) { // identify Create New button driver.FindElement(By.XPath("//*[@id='container']/p/a")).Click(); // Populate Create TM test data collection ExcelLibHelpers.PopulateInCollection(@"A:\TestCases\Login Page\Login Page\TestData\TestData.xls", "TMPage"); //identify code button driver.FindElement(By.Id("Code")).SendKeys(ExcelLibHelpers.ReadData(2, "Code")); //identify description button driver.FindElement(By.Id("Description")).SendKeys(ExcelLibHelpers.ReadData(2, "Description")); //click on Save button driver.FindElement(By.Id("SaveButton")).Click(); // wait // Thread.Sleep(1000); // wait for the TM page to be loaded and Go to last page button rendered Sync.WaitForVisiblitity(driver, "XPath", "//*[@id='tmsGrid']/div[4]/a[4]", 10); // go to the last page driver.FindElement(By.XPath("//*[@id='tmsGrid']/div[4]/a[4]")).Click(); // wait for the TM page to be loaded and Go to last page button rendered Sync.WaitForVisiblitity(driver, "XPath", ".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]", 20); // Implementation of Assertion Assert.That(driver.FindElement(By.XPath(".//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]")).Text, Is.EqualTo(ExcelLibHelpers.ReadData(2, "Code"))); //// verify if T&M present record is presen or not //if (driver.FindElement(By.XPath("//*[@id='tmsGrid']/div[3]/table/tbody/tr[last()]/td[1]")).Text == "Perfect") //{ // Console.WriteLine("TM created successfully, Test Passed"); //} //else //{ // Console.WriteLine("Test Failed"); //} }
internal void EditTimenMaterail() { WebElementExtensions.ElementExists(driver, By.XPath("//a[contains(.,'Edit')]"), TimeSpan.FromSeconds(10)); try { while (true) { for (var i = 1; i <= 10; i++) { IWebElement code = driver.FindElement(By.XPath("//tr[" + i + "]/td[1]")); IWebElement desc = driver.FindElement(By.XPath("//tr[" + i + "]/td[3]")); IWebElement TypeCode = driver.FindElement(By.XPath("//tr[" + i + "]/td[2]")); IWebElement Price = driver.FindElement(By.XPath("//tr[" + i + "]/td[4]")); IWebElement btnedit = driver.FindElement(By.XPath("//tr[" + i + "]/td[5]/a[@class='k-button k-button-icontext k-grid-Edit' and 1]")); Console.WriteLine(code.Text); Console.WriteLine(desc.Text); Console.WriteLine(TypeCode.Text); Console.WriteLine(Price.Text); if (code.Text == ExcelLibHelpers.ReadData(2, "Code") && desc.Text == ExcelLibHelpers.ReadData(2, "Description"))// && TypeCode.Text == "M" && Price.Text == "7.90") { Console.WriteLine("Test Passed"); btnedit.Click(); Id.Clear(); Id.SendKeys(ExcelLibHelpers.ReadData(2, "NewCode"));; Descid.Clear(); Descid.SendKeys(ExcelLibHelpers.ReadData(2, "NewDescription")); driver.FindElement(By.XPath(".//*[@id='TimeMaterialEditForm']/div/div[4]/div/span[1]/span/input[1]")).SendKeys(ExcelLibHelpers.ReadData(2, "PricePerUnit")); driver.FindElement(By.XPath("//input[@id='SaveButton']")).Click(); WebElementExtensions.ElementExists(driver, By.XPath("//a[contains(.,'Edit')]"), TimeSpan.FromSeconds(10)); return; } } nextbtn.Click(); } } catch (Exception) { Console.WriteLine("Test Failed"); } }
public void EditCustomer(IWebDriver driver) { // wait Thread.Sleep(2000); // click on Edit button driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[last()]/a[1]")).Click(); // Handle second window driver.SwitchTo().Frame(driver.FindElement(By.XPath("//*[@id='detailWindow']/iframe"))); // Populate Edit Customer test data collection ExcelLibHelpers.PopulateInCollection(@"A:\TestCases\Login Page\Login Page\TestData\TestData.xls", "CustomerPage"); // remove record from Name button driver.FindElement(By.XPath("//*[@id='Name']")).Clear(); // Fill the value in code button driver.FindElement(By.XPath("//*[@id='Name']")).SendKeys(ExcelLibHelpers.ReadData(3, "Name")); // Click on Edit Contact driver.FindElement(By.XPath("//*[@id='EditContactButton']")).Click(); Thread.Sleep(1000); // Handle third window driver.SwitchTo().Frame(driver.FindElement(By.XPath("//*[@id='contactDetailWindow']/iframe"))); // identify First Name button of Edit Contact driver.FindElement(By.XPath("//*[@id='FirstName']")).SendKeys(ExcelLibHelpers.ReadData(3, "FirstName")); // identify Last Name botton of Edit Contact driver.FindElement(By.XPath("//*[@id='LastName']")).SendKeys(ExcelLibHelpers.ReadData(3, "LastName")); // identify the Phone botton of Edit contact driver.FindElement(By.XPath("//*[@id='Phone']")).SendKeys(ExcelLibHelpers.ReadData(3, "Phone")); // CLICK on SaveContact button driver.FindElement(By.XPath("//*[@id='submitButton'][@value='Save Contact']")).Click(); // back to second window driver.SwitchTo().DefaultContent(); //wait Thread.Sleep(1000); // Handle second window driver.SwitchTo().Frame(driver.FindElement(By.XPath("//*[@id='detailWindow']/iframe"))); // click on save button driver.FindElement(By.XPath("//*[@id='submitButton'][@value='Save']")).Click(); // wait Thread.Sleep(1000); // Implementation of Assertion Assert.That(driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[2]")).Text, Is.EqualTo(ExcelLibHelpers.ReadData(3, "Name"))); //// verify if Customer editing function work or not //if (driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[2]")).Text == "Industry") //{ // Console.WriteLine("Customer edited successfully, Test Passed"); //} //else //{ // Console.WriteLine("Test Failed"); //} }
public void addEducation() { //Wait until the edit button for adding aducation details is visible Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[4]/div/div[2]/div/table/thead/tr/th[6]/div"); //Click on the add new button for adding a new entry for the education details addNewEducationButton.Click(); //Wait until the he College/University text box is present Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[4]/div/div[2]/div/div/div[1]/div[1]/input"); //Pass the filename and sheetname of the excel sheet ExcelLibHelpers.PopulateInCollection(@"D:\Internship\Onboarding_task\SkillExchange\SkillExchange\TestData\TestData.xls", "HomePage"); //Read the College name from the excel var collegeData = ExcelLibHelpers.ReadData(2, "College/University Name"); //add the required college addCollege.SendKeys(collegeData); SelectElement countrySelect = new SelectElement(countryDrpdwn); //Read the country name from the excel var countryData = ExcelLibHelpers.ReadData(2, "Country of College/University"); //Select the required country from the dropdown countrySelect.SelectByText(countryData); SelectElement titleSelect = new SelectElement(titleDrpdwn); //Read the title name from the excel var titleData = ExcelLibHelpers.ReadData(2, "Title"); //Select the required title from the dropdown titleSelect.SelectByText(titleData); //Read the degree data from the excel var degreeData = ExcelLibHelpers.ReadData(2, "Degree"); //Enter the required degree to the education addDegree.SendKeys(degreeData); SelectElement year = new SelectElement(graduateYearDrpdwn); //Read the degree data from the excel var yearData = ExcelLibHelpers.ReadData(2, "Year of graduation"); //Select the required title from the dropdown year.SelectByText(yearData); //Click on the add button to add all the education details educationDetailsAddButton.Click(); //Get the message displayed on the pop up after education details are added getPopText(); //wait until the details appear Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[4]/div/div[2]/div/table/tbody/tr/td[1]"); //Validate the details added in the Education tab if ((country.Text == countryData) && (university.Text == collegeData) && (Title.Text == titleData) && (Degree.Text == degreeData) && (graduationYear.Text == yearData)) { Assert.Pass("Test Passed, Education details has been added succesfully"); } else { Assert.Fail("Test Failed, Education details has not been added succesfully"); } }
internal void CreateTimeAndMaterial() { // For Creating First Record Id.SendKeys(ExcelLibHelpers.ReadData(2, "Code")); Descid.SendKeys(ExcelLibHelpers.ReadData(2, "Description")); driver.FindElement(By.XPath(".//*[@id='TimeMaterialEditForm']/div/div[4]/div/span[1]/span/input[1]")).SendKeys(ExcelLibHelpers.ReadData(2, "PricePerUnit")); driver.FindElement(By.XPath("//input[@id='SaveButton']")).Click(); //WebElementExtensions.ElementExists(driver, By.Name(""), TimeSpan.FromDays(1)); }
public void addDetails() { //Click on Add Availability addAvailability.Click(); Thread.Sleep(500); SelectElement availabilitySelect = new SelectElement(availabilityDrpdwn); //Pass the filename and sheetname of the excel sheet ExcelLibHelpers.PopulateInCollection(@"D:\Internship\Onboarding_task\SkillExchange\SkillExchange\TestData\TestData.xls", "HomePage"); //Read the availability data fom the excel var availabilityData = ExcelLibHelpers.ReadData(2, "Availability"); //Select the required availability option from the dropdown availabilitySelect.SelectByText(availabilityData); getPopText(); //Click on add hours addHours.Click(); Thread.Sleep(500); SelectElement availabilityHourSelect = new SelectElement(availabilityHourDrpdwn); //Read the hours data from the excel var hoursData = ExcelLibHelpers.ReadData(2, "Hours"); //Select the required availability hour value from the dropdown availabilityHourSelect.SelectByText(hoursData); getPopText(); //Click to add Earn Target details addEarnTarget.Click(); Thread.Sleep(500); SelectElement availabiltyTargetSelect = new SelectElement(availabiltyTargetDrpdwn); //Read the data for the Earn Target from the excel var earnTargetData = ExcelLibHelpers.ReadData(2, "Earn Target"); //Select the required target value from the dropdown availabiltyTargetSelect.SelectByText(earnTargetData); getPopText(); //Validate if the details are added correctly string availability = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[3]/div/div[2]/div/span")).Text; string hours = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[3]/div/div[3]/div/span")).Text; string earnTarget = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[2]/div/div/div/div/div/div[3]/div/div[4]/div/span")).Text; if ((availability == availabilityData) && (hours == hoursData) && (earnTarget == earnTargetData)) { Assert.Pass("Test Passed!! Availability, Hours and Earn Target details has been added to the profile successfully"); } else { Assert.Fail("Test Failed, Availability, Hours and Earn Target details has not been added to the profile successfully"); } }
public void addSkills() { var skillData = new string[4]; var skillLevelData = new string[4]; bool firstColumnCheck = false; bool secondColumnCheck = false; bool[] rowCheck = new bool[4]; int entries = 4; //Pass the filename and sheetname of the excel sheet ExcelLibHelpers.PopulateInCollection(@"D:\Internship\Onboarding_task\SkillExchange\SkillExchange\TestData\TestData.xls", "HomePage"); for (int entryCount = 0; entryCount < entries; entryCount++) { //Wait until add new button is present Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[3]/div/div[2]/div/table/thead/tr/th[3]/div"); //Click on add new button for Skills addNewSkillButton.Click(); //Read the skill from the excel skillData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 2, "Skill"); //Wait until add skill text box is visible Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[3]/div/div[2]/div/div/div[1]/input"); //add the required skill addSkill.SendKeys(skillData[entryCount]); SelectElement levelSelect = new SelectElement(skillLevelDrpdwn); //Read the skill Level from the excel skillLevelData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 2, "SkillLevel"); //Select the required level from the dropdown levelSelect.SelectByText(skillLevelData[entryCount]); //Click on the add button to add all the skill details skillDetailsAddButton.Click(); //Get the message displayed in the pop after each skill details are updated getPopText(); } //Wait until the skill details are added and are visible Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[3]/div/div[2]/div/table/tbody/tr/td[1]"); //Idenitfy the table that stores the data for the Skill IWebElement table = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[3]/div/div[2]/div/table")); //Get the list of rows in the table for the last Page IList <IWebElement> skillRows = table.FindElements(By.TagName("tr")); //Get the list of columns IList <IWebElement> columnsFirstRow = skillRows[1].FindElements(By.TagName("td")); IWebElement Column; //Validate if all the entries for the language is added successfully and correctly by checking the table values for (int entry = 1; entry < skillRows.Count; entry++) { for (int col = 1; col < columnsFirstRow.Count; col++) { //Access each column value in the table Column = 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[" + (entry) + "]/tr/td[" + col + "]")); if (col == 1) { if (Column.Text == skillData[entry - 1]) { firstColumnCheck = true; } } else if (col == 2) { if (Column.Text == skillLevelData[entry - 1]) { secondColumnCheck = true; } } } //Validate each entry for Language updated in the page by checking the column values rowCheck[entry - 1] = firstColumnCheck && secondColumnCheck; //Check if both Skills and Level values updated in the page matches with the data in excel if (rowCheck[entry - 1]) { TestContext.WriteLine($" Entry {entry} for the skill is added correctly"); } else { TestContext.WriteLine($" Entry {entry} for the skill is not added correctly"); } //Set the check values to false before next iteration firstColumnCheck = false; secondColumnCheck = false; } //Validate if all the added entries in the table match with the value provided if (rowCheck[0] && rowCheck[1] && rowCheck[2] && rowCheck[3]) { Assert.Pass("Test Passed, Skill details has been added correctly"); } else { Assert.Fail("Test Failed, Skill details has not been added correctly"); } }
internal void editing() { driver.FindElement(By.XPath("//a[@href='#'][contains(.,'Administration')]")).Click(); driver.FindElement(By.XPath("//a[@href='/TimeMaterial']")).Click(); Wait.ElementIsVisible(driver, "//span[@class='k-icon k-i-arrow-e'][contains(.,'Go to the next page')]", "XPath"); try { while (true) { for (int i = 1; i <= 10; i++) { IWebElement code = driver.FindElement(By.XPath("//*[@id=\"tmsGrid\"]/div[3]/table/tbody/tr[" + i + "]/td[1]")); if (code.Text == "SUB") { driver.FindElement(By.XPath("(//a[contains(.,'Edit')])[8]")).Click(); Thread.Sleep(3000); ExcelLibHelpers.PopulateInCollection(@"C:\Users\Owner\source\repos\Firstautomation\Firstautomation\TestData\TestData.xls", "Mysheet"); driver.FindElement(By.XPath("//input[@id='Code']")).Clear(); driver.FindElement(By.XPath("//input[@id='Code']")).SendKeys(ExcelLibHelpers.ReadData(3, "Code")); driver.FindElement(By.XPath("//input[@id='Description']")).Clear(); driver.FindElement(By.XPath("//input[@id='Description']")).SendKeys(ExcelLibHelpers.ReadData(3, "Description")); // driver.FindElement(By.Id("Price")).Clear(); // driver.FindElement(By.XPath("//*[@id=\"Price\"]")).SendKeys("50000"); Thread.Sleep(3000); driver.FindElement(By.XPath("//input[@id='SaveButton']")).Click(); } } driver.FindElement(By.XPath("//span[@class='k-icon k-i-arrow-e'][contains(.,'Go to the next page')]")).Click(); } } catch (Exception) { Console.WriteLine("code not found"); } }
public void addTM(IWebDriver driver) { ExcelLibHelpers.PopulateInCollection(@"/Users/oiyo/Projects/IndustryconnectSpecFlow/IndustryconnectSpecFlow/TestData.xlsx", "TimeAndMaterialPage"); //Navigate to Time and Material page IWebElement administration = driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/a")); administration.Click(); //Click on Time and management IWebElement timeAndManagement = driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/ul/li[3]")); timeAndManagement.Click(); //Create a new time and material IWebElement createNew = driver.FindElement(By.XPath("//*[@id=\"container\"]/p/a")); createNew.Click(); //select time in typecode IWebElement typeCode = driver.FindElement(By.XPath("//*[@id=\"TimeMaterialEditForm\"]/div/div[1]/div")); typeCode.Click(); IWebElement time = driver.FindElement(By.XPath("//*[@id=\"TimeMaterialEditForm\"]/div/div[1]/div/span[1]/span/span[1]")); time.Click(); IWebElement timeoption = driver.FindElement(By.XPath("//*[@id=\"TypeCode_listbox\"]/li[2]")); timeoption.Click(); //enter code IWebElement code = driver.FindElement(By.Id("Code")); code.SendKeys(ExcelLibHelpers.ReadData(2, "Code")); //enter description IWebElement description = driver.FindElement(By.Id("Description")); description.SendKeys(ExcelLibHelpers.ReadData(2, "Description")); //enter price per unit IWebElement pricePerUnit = driver.FindElement(By.XPath("//*[@id=\"TimeMaterialEditForm\"]/div/div[4]/div/span[1]/span/input[1]")); pricePerUnit.SendKeys(ExcelLibHelpers.ReadData(2, "Price")); //Click on save button IWebElement save = driver.FindElement(By.XPath("//*[@id=\"SaveButton\"]")); save.Click(); //Check if the time and management is created sucessfully //Thread.Sleep(1000); Wait.WaitForElementPresentAndEnabled(By.XPath(".//*[@title='Go to the last page']"), 3); IWebElement lastPage = driver.FindElement(By.XPath("//*[@title=\"Go to the last page\"]")); lastPage.Click(); /*IWebElement codeToCheck = driver.FindElement(By.XPath("//td[text()='Oiyo']")); * if (codeToCheck.Text == "Oiyo") * { * Console.WriteLine("Time and Management created successfully"); * * } * else * { * Console.WriteLine("Test Failed"); * }*/ }
public void FillDetailsOfServiceProvided() { //Wait for the share skill page to be loaded and until title field text box is visible Wait.ElementIsVisible(driver, "XPath", "//*[@id='service-listing-section']/div[2]/div/form/div[1]/div/div[2]/div/div[1]/input"); //Read the data for Title from excel and enter the data into the Title Textbox Title.SendKeys(ServiceData.TitleData(RowNum)); //Read the data for Description from excel and enter the data into the Description Textbox Description.SendKeys(ServiceData.DescriptionData(RowNum)); //Read the Category name from the excel var CategoryData = ServiceData.CategData(RowNum); //Read the Subcategory name from the excel var SubCategoryData = ServiceData.SubCategData(RowNum); SelectElement CategorySelect = new SelectElement(Category); //Select the required Category from the dropdown CategorySelect.SelectByText(CategoryData); SelectElement SubCategorySelect = new SelectElement(SubCategory); //Select the required SubCategory from the dropdown SubCategorySelect.SelectByText(SubCategoryData); //Read the Skill exchange tag count from the excel var SkillExchngCount = ServiceData.TagsCntData(RowNum); int Count = Int32.Parse(SkillExchngCount); int TagsCount = Int32.Parse(ServiceData.TagsDataCount(RowNum)); int DaysCnt = Int32.Parse(ServiceData.AvailableDaysCnt(RowNum)); //Fill in the Start and End times for all days for (int TagCount = 0; TagCount < TagsCount; TagCount++) { //Read the data for Tags from excel and enter the data into the Tags field Tags.SendKeys(ExcelLibHelpers.ReadData((TagCount + RowNum), "Tags")); //Press ENTER key to add the tag Tags.SendKeys(Keys.Enter); } //Read the Service Type data from excel into a variable var ServiceTypeData = ServiceData.SrvcTypeData(RowNum); //Read the Location Type data from excel into a variable var LocationTypeData = ServiceData.LocatnTypeData(RowNum); //Read the Skill Trade data from excel into a variable var SkillTradeData = ServiceData.SkillTrdeData(RowNum); //Read the Active Status data from excel into a variable var ActiveStatusData = ServiceData.ActvStatusData(RowNum); //Choose Service Type ChooseServiceType(ServiceTypeData); //Choose Location Type ChooseLocationType(LocationTypeData); //Choose Skill Trade ChooseSkillTrade(SkillTradeData, Count); //Click on the 'Start date' field StartDate.Click(); //Read the Start Date data from the excel var StartDateData = ServiceData.StrtDateData(RowNum); //Read the End Date data from the excel var EndDateData = ServiceData.EndDateData(RowNum); //Initialse the variable that hold StartTime and EndTime var StartTimeData = "000000"; var EndTimeData = "000000"; //Clear the field before adding the date StartDate.Clear(); //Enter the data for 'Start date' from excel StartDate.SendKeys(StartDateData); Wait.wait(1, driver); //Click on the 'End date' field EndDate.Click(); //Clear the 'End date' EndDate.Clear(); //Enter the data for 'End date' from excel EndDate.SendKeys(EndDateData); //Select the Start time, End time, Available Days for (int DaysCount = 0; DaysCount < DaysCnt; DaysCount++) { if (ServiceData.AvailableDays(RowNum) == "Sun") { CheckBox[0].Click(); StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); StartTime[0].Click(); StartTime[0].SendKeys(StartTimeData); EndTime[0].Click(); EndTime[0].SendKeys(EndTimeData); } else if (ServiceData.AvailableDays(RowNum) == "Mon") { StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); CheckBox[1].Click(); StartTime[1].Click(); StartTime[1].SendKeys(StartTimeData); EndTime[1].Click(); EndTime[1].SendKeys(EndTimeData); } else if (ServiceData.AvailableDays(RowNum) == "Tue") { StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); CheckBox[2].Click(); StartTime[2].Click(); StartTime[2].SendKeys(StartTimeData); EndTime[2].Click(); EndTime[2].SendKeys(EndTimeData); } else if (ServiceData.AvailableDays(RowNum) == "Wed") { StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); CheckBox[3].Click(); StartTime[3].Click(); StartTime[3].SendKeys(StartTimeData); EndTime[3].Click(); EndTime[3].SendKeys(EndTimeData); } else if (ServiceData.AvailableDays(RowNum) == "Thu") { StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); CheckBox[4].Click(); StartTime[4].Click(); StartTime[4].SendKeys(StartTimeData); EndTime[4].Click(); EndTime[4].SendKeys(EndTimeData); } else if (ServiceData.AvailableDays(RowNum) == "Fri") { StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); CheckBox[5].Click(); StartTime[5].Click(); StartTime[5].SendKeys(StartTimeData); EndTime[5].Click(); EndTime[5].SendKeys(EndTimeData); } else { StartTimeData = ServiceData.StrtTimeData(RowNum); EndTimeData = ServiceData.EndTimeData(RowNum); CheckBox[6].Click(); StartTime[6].Click(); StartTime[6].SendKeys(StartTimeData); EndTime[6].Click(); EndTime[6].SendKeys(EndTimeData); } RowNum++; } //Choose the Active status button ChooseActiveStatus(ActiveStatusData); //Click on the save button SaveButton.Click(); //Implicit wait Wait.wait(1, driver); }
public void AddCustomerTest(IWebDriver driver) { // To Click on Administration button driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/a")).Click(); // To click on Customer button driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/ul/li[1]/a")).Click(); //To Click on Create New button driver.FindElement(By.XPath("//*[@id='container']/p/a")).Click(); //Populate Loging Page test data Collection ExcelLibHelpers.PopulateInCollection(@"C:\Users\myfri\Source\Repos\pavulurikc\chowdary\Chowdary\TestData\TestData.xls", "CustomerPage"); //To enter Text in Name field driver.FindElement(By.XPath("//*[@id='Name']")).SendKeys(ExcelLibHelpers.ReadData(2, "Name")); //To Click Edit Contact Button driver.FindElement(By.XPath("//*[@id='EditContactButton']")).Click(); Thread.Sleep(1000); driver.SwitchTo().Frame(driver.FindElement(By.XPath("//*[@id='contactDetailWindow']/iframe"))); //To enter text in FirstName Field driver.FindElement(By.XPath("//*[@id='FirstName']")).SendKeys(ExcelLibHelpers.ReadData(2, "FirstName")); driver.FindElement(By.XPath("//*[@id='LastName']")).SendKeys(ExcelLibHelpers.ReadData(2, "LastName")); driver.FindElement(By.XPath("//*[@id='Phone']")).SendKeys(ExcelLibHelpers.ReadData(2, "Phone")); driver.FindElement(By.XPath("//*[@id='submitButton']")).Click(); driver.SwitchTo().DefaultContent(); driver.FindElement(By.XPath("//*[@id='EditBillingContactButton']")).Click(); driver.SwitchTo().Frame(driver.FindElement(By.XPath("//*[@id='contactDetailWindow']/iframe"))); Thread.Sleep(4000); //driver.FindElement(By.XPath("//*[@id='IsSameContact']")).Click(); driver.FindElement(By.XPath("//*[@id='FirstName']")).SendKeys(ExcelLibHelpers.ReadData(2, "FirstName")); driver.FindElement(By.XPath("//*[@id='LastName']")).SendKeys(ExcelLibHelpers.ReadData(2, "LastName")); driver.FindElement(By.XPath("//*[@id='Phone']")).SendKeys(ExcelLibHelpers.ReadData(2, "Phone")); //Thread.Sleep(1000); driver.FindElement(By.XPath("//*[@id='submitButton']")).Click(); driver.SwitchTo().DefaultContent(); Thread.Sleep(2000); driver.FindElement(By.XPath("//*[@id='submitButton']")).Click(); // To Click on Administration button driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/a")).Click(); // To click on Customer button driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/ul/li[1]/a")).Click(); Thread.Sleep(4000); driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[4]/a[4]/span")).Click(); if (driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[2]")).Text == "Ram") { Console.WriteLine("TM created successfully, test passed"); } else { Console.WriteLine("test failed"); } }
public void addCertifications() { //Pass the filename and sheetname of the excel sheet ExcelLibHelpers.PopulateInCollection(@"D:\Internship\Onboarding_task\SkillExchange\SkillExchange\TestData\TestData.xls", "HomePage"); var certificateData = new string[4]; var certifiedFromData = new string[4]; var certificationYearData = new string[4]; bool firstColumnCheck = false; bool secondColumnCheck = false; bool thirdColumnCheck = false; bool[] rowCheck = new bool[4]; int entries = 4; //Add all the certification details in the profile for (int entryCount = 0; entryCount < entries; entryCount++) { //Wait until add new button is present Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/table/thead/tr/th[4]/div"); //Click on the add new button to add the details addNewCertificationButton.Click(); //Wait until the certificate text box is available Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/div/div[1]/div/input"); //Read the name from the excel certificateData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 2, "Certificate/Award"); //Add the required certificate details addCertificate.SendKeys(certificateData[entryCount]); //Read the Certified From Data from the excel certifiedFromData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 2, "Certified From"); //Add the data for the 'Çertified From' field certifiedFrom.SendKeys(certifiedFromData[entryCount]); SelectElement yearSelect = new SelectElement(yearDrpdwn); //Read the Certified From Data from the excel certificationYearData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 2, "Year of certification"); //Select the required year from the dropdown yearSelect.SelectByText(certificationYearData[entryCount]); //Click on the add button to add the details certificationDetailsAddButton.Click(); //Get the message displayed on the pop up after certification details are added getPopText(); } //Wait until the certificate for text box is visible Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/table/tbody/tr/td[1]"); //Idenitfy the table that stores the data for the Certification IWebElement table = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/table")); //Get the list of rows in the table IList <IWebElement> certRows = table.FindElements(By.TagName("tr")); //Get the list of columns IList <IWebElement> columnsFirstRow = certRows[1].FindElements(By.TagName("td")); IWebElement Column; //Validate if all the entries for the language is added successfully and correctly by checking the table values for (int entry = 1; entry < certRows.Count; entry++) { for (int col = 1; col < columnsFirstRow.Count; col++) { //Access each column value in the table Column = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/table/tbody[" + (entry) + "]/tr/td[" + col + "]")); if (col == 1) { if (Column.Text == certificateData[entry - 1]) { firstColumnCheck = true; } } else if (col == 2) { if (Column.Text == certifiedFromData[entry - 1]) { secondColumnCheck = true; } } else if (col == 3) { if (Column.Text == certificationYearData[entry - 1]) { thirdColumnCheck = true; } } } //Validate each entry for certificate updated in the page by checking the column values rowCheck[entry - 1] = firstColumnCheck && secondColumnCheck && thirdColumnCheck; //Check if certificate, From and Year values updated in the page match with the data in excel if (rowCheck[entry - 1]) { TestContext.WriteLine($" Entry {entry} data for the certification is added correctly"); } else { TestContext.WriteLine($" Entry {entry} data for the certification is not added correctly"); } //Set the check values to false before next iteration firstColumnCheck = false; secondColumnCheck = false; thirdColumnCheck = false; } //Validate if all the added entries in the table match with the value provided if (rowCheck[0] && rowCheck[1] && rowCheck[2] && rowCheck[3]) { Assert.Pass("Test Passed, Certifications details has been added correctly"); } else { Assert.Fail("Test Failed, Certifications details has not been added correctly"); } }
internal void deleteTimenMaterial() { // WebElementExtensions.ElementExists(driver, By.XPath("//tr[1]/td[5]/a[@class='k-button k-button-icontext k-grid-Delete' and 2]"), TimeSpan.FromSeconds(10)); WebElementExtensions.ElementExists(driver, By.XPath("//a[contains(.,'Edit')]"), TimeSpan.FromSeconds(10)); try { while (true) { for (var i = 1; i <= 10; i++) { IWebElement code = driver.FindElement(By.XPath("//tr[" + i + "]/td[1]")); IWebElement desc = driver.FindElement(By.XPath("//tr[" + i + "]/td[3]")); IWebElement TypeCode = driver.FindElement(By.XPath("//tr[" + i + "]/td[2]")); IWebElement Price = driver.FindElement(By.XPath("//tr[" + i + "]/td[4]")); IWebElement btndelete = driver.FindElement(By.XPath("//tr[" + i + "]/td[5]/a[@class='k-button k-button-icontext k-grid-Delete' and 2]")); Console.WriteLine(code.Text); Console.WriteLine(desc.Text); Console.WriteLine(TypeCode.Text); Console.WriteLine(Price.Text); if (code.Text == ExcelLibHelpers.ReadData(2, "Code") && desc.Text == ExcelLibHelpers.ReadData(2, "Description")) //if (code.Text == "SSRR112" && desc.Text == "SSRR112")// && TypeCode.Text == "M" && Price.Text == "7.90") { Console.WriteLine("Test Passed"); btndelete.Click(); Thread.Sleep(2000); driver.SwitchTo().Alert().Accept(); Thread.Sleep(2000); //Deletbtn.Click(); //Editbtn.Click(); //Id.Clear(); //Id.SendKeys("Testnew"); //Descid.SendKeys("Test Descritionnew"); //driver.FindElement(By.XPath(".//*[@id='TimeMaterialEditForm']/div/div[4]/div/span[1]/span/input[1]")).SendKeys("7.90"); //driver.FindElement(By.XPath("//input[@id='SaveButton']")).Click(); //WebElementExtensions.ElementExists(driver, By.XPath("//a[contains(.,'Edit')]"), TimeSpan.FromSeconds(10)); return; } } nextbtn.Click(); } } catch (Exception) { Console.WriteLine("Test Failed"); } }
public void checkDuplicateEntries() { //Pass the filename and sheetname of the excel sheet ExcelLibHelpers.PopulateInCollection(@"D:\Internship\Onboarding_task\SkillExchange\SkillExchange\TestData\TestData.xls", "HomePage"); var certificateData = new string[2]; var certifiedFromData = new string[2]; var certificationYearData = new string[2]; int entries = 2; //Add all the certification details in the profile for (int entryCount = 0; entryCount < entries; entryCount++) { //Wait until add new button is present Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/table/thead/tr/th[4]/div"); //Click on the add new button to add the details addNewCertificationButton.Click(); //Wait until the certificate text box is available Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[5]/div[1]/div[2]/div/div/div[1]/div/input"); //Read the data from the excel certificateData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 6, "Certificate/Award"); //Add the required certificate details addCertificate.SendKeys(certificateData[entryCount]); //Read the Certified From Data from the excel certifiedFromData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 6, "Certified From"); //Add the data for the 'Çertified From' field certifiedFrom.SendKeys(certifiedFromData[entryCount]); SelectElement yearSelect = new SelectElement(yearDrpdwn); //Read the Certified From Data from the excel certificationYearData[entryCount] = ExcelLibHelpers.ReadData(entryCount + 6, "Year of certification"); //Select the required year from the dropdown yearSelect.SelectByText(certificationYearData[entryCount]); //Click on the add button to add the details certificationDetailsAddButton.Click(); //Wait until the pop up appears Wait.ElementIsVisible(driver, "XPath", "//div[@class='ns-box-inner']"); Thread.Sleep(1000); if (entryCount == 0) { //Get the text from the pop up String msg = driver.FindElement(By.XPath("//div[@class='ns-box-inner']")).Text; TestContext.WriteLine(msg); Thread.Sleep(1000); //Close the pop up before adding next entry driver.FindElement(By.XPath("//a[@class='ns-close']")).Click(); Thread.Sleep(1000); } else { String validateMsg = driver.FindElement(By.XPath("//div[@class='ns-box-inner']")).Text; if (validateMsg == "This information is already exist.") { Assert.Pass("Test Passed, Duplicate entry is not allowed and pop up message is displayed"); } else { Assert.Fail("Test Failed!!!"); } } } }
internal void ValidateTimenMaterial() { WebElementExtensions.ElementExists(driver, By.XPath("//a[contains(.,'Edit')]"), TimeSpan.FromSeconds(10)); try { while (true) { for (var i = 1; i <= 10; i++) { IWebElement code = driver.FindElement(By.XPath("//tr[" + i + "]/td[1]")); IWebElement desc = driver.FindElement(By.XPath("//tr[" + i + "]/td[3]")); IWebElement TypeCode = driver.FindElement(By.XPath("//tr[" + i + "]/td[2]")); IWebElement Price = driver.FindElement(By.XPath("//tr[" + i + "]/td[4]")); //IWebElement Editbtn = driver.FindElement(By.XPath("//tr[" + i + "]/td[5]/a[@class='k-button k-button-icontext k-grid-Edit' and 1]")); Console.WriteLine(code.Text); Console.WriteLine(desc.Text); Console.WriteLine(TypeCode.Text); Console.WriteLine(Price.Text); if (code.Text == ExcelLibHelpers.ReadData(2, "Code") && desc.Text == ExcelLibHelpers.ReadData(2, "Description"))// && TypeCode.Text == "M" && Price.Text == "7.90") { Console.WriteLine("Test Passed"); //Editbtn.Click(); return; } } nextbtn.Click(); } } catch (Exception) { Console.WriteLine("Test Failed"); } }
public void editLanguages() { //Pass the filename and sheetname of the excel sheet ExcelLibHelpers.PopulateInCollection(@"D:\Internship\Onboarding_task\SkillExchange\SkillExchange\TestData\TestData.xls", "HomePage"); //Read the degree data from the excel var UpdateLang = ExcelLibHelpers.ReadData(6, "Language"); var UpdateLangLevel = ExcelLibHelpers.ReadData(6, "LanguageLevel"); //Identify the language table IWebElement table = driver.FindElement(By.XPath("//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/table")); //Get the list of rows in the table IList <IWebElement> languageRows = table.FindElements(By.TagName("tr")); //If the are atleast 1 entry for language if (languageRows.Count > 1) { //Wait until edit button is present Wait.ElementPresent(driver, "XPath", "//*[@id='account-profile-section']/div/section[2]/div/div/div/div[3]/form/div[2]/div/div[2]/div/table/tbody[last()]/tr/td[3]/span[1]"); //Identify the Edit button of the last entry in the table 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[last()]/tr/td[3]/span[1]")).Click(); //Wait for the edit mode to be visible Thread.Sleep(100); //Identify the add language box to be updated IWebElement editLanguage = driver.FindElement(By.XPath("//input[@placeholder='Add Language']")); //Clear the data editLanguage.Clear(); //Enter the updated data editLanguage.SendKeys(UpdateLang); //Identify the level dropdown box to update IWebElement editLanguageLevel = driver.FindElement(By.XPath("//select[@name='level']")); SelectElement Editlevel = new SelectElement(editLanguageLevel); Editlevel.SelectByText(UpdateLangLevel); Thread.Sleep(100); //Idenitfy the Update button 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[last()]/tr/td/div/span/input[1]")).Click(); //Get the message displayed in the pop up getPopText(); //Get the First Column value from last entry in the table String updatedLang = 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[last()]/tr/td[1]")).Text; //Get the Second Column value from last entry in the table String updatedLangLevel = 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[last()]/tr/td[2]")).Text; //Validate the updated language entry if ((updatedLang == UpdateLang) && (updatedLangLevel == UpdateLangLevel)) { Assert.Pass("Test Passed, Language details are updated correctly"); } else { Assert.Fail("Test Failed, Language details are not updated correctly"); } } //Display error message and fail the test if there are no entries to be edited else { Assert.Fail("Edit cannot be performed, there are no language records to be edited"); } }
internal void EnterShareSkill(IWebDriver driver) { CommomDriver.Wait(2000); //populate login page data collection ExcelLibHelpers.PopulateInCollection(MarsResource.ExcelPath, "EnterShareSkill"); //Wait untill driver find title text Field CommomDriver.WaitForVisibility(driver, "Name", "title", 2); //Give a Title Title.SendKeys(ExcelLibHelpers.ReadData(2, "Title")); //Give a Description Description.SendKeys(ExcelLibHelpers.ReadData(2, "Description")); //select one of the option from Category Category.SendKeys(ExcelLibHelpers.ReadData(2, "Category")); ////Select SubCategory Option SubCategory.SendKeys(ExcelLibHelpers.ReadData(2, "Sub Category")); //give input in Tag TextField Tag.SendKeys(ExcelLibHelpers.ReadData(2, "Tag") + Keys.Enter); //choose Radio button option ServiceType.Click(); //Choose Location Location.Click(); //Give StartDate StartDate.SendKeys(ExcelLibHelpers.ReadData(2, "Start Date")); //Give EndDate EndDate.SendKeys(ExcelLibHelpers.ReadData(2, "End Date")); for (int i = 2; i < 9; i++) { for (int j = 2; j < 9; j++) { IWebElement SatrtTime = driver.FindElement(By.XPath("//div[" + i + "]/div[2]/input")); IWebElement EndTime = driver.FindElement(By.XPath("//div[" + j + "]/div[3]/input")); if (i == 2 && j == 2) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(2, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(2, "End Time")); } if (i == 3 && j == 3) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(3, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(3, "End Time")); } if (i == 4 && j == 4) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(4, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(4, "End Time")); } if (i == 5 && j == 5) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(5, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(5, "End Time")); } if (i == 6 && j == 6) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(6, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(6, "End Time")); } if (i == 7 && j == 7) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(7, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(7, "End Time")); } if (i == 8 && j == 8) { SatrtTime.SendKeys(ExcelLibHelpers.ReadData(8, "Start Time")); EndTime.SendKeys(ExcelLibHelpers.ReadData(8, "End Time")); } else { continue; } } } //Click on Share Trade Radio Button SkillTrade.Click(); //give inpute Skill Exchange SkillExchange.SendKeys(ExcelLibHelpers.ReadData(2, "Skill Exchange") + Keys.Enter); //Click on Work Sample WorkSample.Click(); //Handle the window that not belongs to Browser -AutoIt - see blog for more info //below line execute the AutoIT script //Create an object for AutoIt AutoItX3 autoIt = new AutoItX3(); //This statement Active the window and perform set of auctions autoIt.WinActivate("Open"); Thread.Sleep(1000); //set the path to open the file on browser autoIt.Send(@"D:\InternPro\InternProject2\AutoIt\scrummeeting.png"); Thread.Sleep(1000); //It will click on "Open" button autoIt.Send("{ENTER}"); //click on active radio button Active.Click(); //click on save button savebtn.Click(); //For Assertion- Go to manage list ManageList.Click(); //Get the text from manage list of Title and Category String ManageTitle = TitleofManage.Text; String ManageListCategory = CategoryofManage.Text; try { //For Assertion - After Save Skills For varification, //Goto manage list page and match Title and Cetegory with Excel Enter Skill Assert.AreEqual(ManageTitle, ExcelLibHelpers.ReadData(2, "Title")); Assert.AreEqual(ManageListCategory, ExcelLibHelpers.ReadData(2, "Category")); } catch (Exception e) { Console.WriteLine(e.Message); } }
public void AddCustome(IWebDriver driver) { // identify Create New button driver.FindElement(By.XPath("//*[@id='container']/p/a")).Click(); // Populate Add Customer test data collection ExcelLibHelpers.PopulateInCollection(@"A:\TestCases\Login Page\Login Page\TestData\TestData.xls", "CustomerPage"); //identify Name button driver.FindElement(By.XPath("//*[@id='Name']")).SendKeys(ExcelLibHelpers.ReadData(2, "Name")); //identify Edit Contact button driver.FindElement(By.XPath("//*[@id='EditContactButton']")).Click(); //wait //Thread.Sleep(1000); // wait for the Edit Contact page to be loaded and First name, LastName textbox rendered Sync.WaitForVisiblitity(driver, "XPath", "//*[@id='contactDetailWindow']/iframe", 10); // Handle second window driver.SwitchTo().Frame(driver.FindElement(By.XPath("//*[@id='contactDetailWindow']/iframe"))); // identify First Name of edit contact driver.FindElement(By.XPath("//*[@id='FirstName']")).SendKeys(ExcelLibHelpers.ReadData(2, "FirstName")); // identify Last Name botton of Edit Contact driver.FindElement(By.XPath("//*[@id='LastName']")).SendKeys(ExcelLibHelpers.ReadData(2, "LastName")); // identify the Phone botton of Edit contact driver.FindElement(By.XPath("//*[@id='Phone']")).SendKeys(ExcelLibHelpers.ReadData(2, "Phone")); //click on Save Edit contact button driver.FindElement(By.XPath(".//*[@id='submitButton' ][@value='Save Contact']")).Click(); driver.SwitchTo().DefaultContent(); // click on Save as above driver.FindElement(By.XPath("//*[@id='IsSameContact']")).Click(); // Click on save button driver.FindElement(By.XPath(".//*[@id='submitButton' ]")).Click(); // click on administration driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/a")).Click(); // Click on Customer driver.FindElement(By.XPath("/html/body/div[3]/div/div/ul/li[5]/ul/li[1]/a")).Click(); // wait // Thread.Sleep(3000); // wait for the Customer page to be loaded and Go to Last Page button rendered Sync.WaitForVisiblitity(driver, "XPath", "//*[@id='clientsGrid']/div[4]/a[4]", 10); // go to the last page driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[4]/a[4]")).Click(); // wait //Thread.Sleep(1000); // wait for the Last record of Customer page to be loaded and new record to be display Sync.WaitForVisiblitity(driver, "XPath", "//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[2]", 10); // Implementation of Assertion Assert.That(driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[2]")).Text, Is.EqualTo(ExcelLibHelpers.ReadData(2, "Name"))); //// verify if Customer record is present or not //if (driver.FindElement(By.XPath("//*[@id='clientsGrid']/div[2]/table/tbody/tr[last()]/td[2]")).Text == "Bharati") //{ // Console.WriteLine("Customer created successfully, Test Passed"); //} //else //{ // Console.WriteLine("Test Failed"); //} }