|
| 1 | +using Microsoft.VisualStudio.TestTools.UnitTesting; |
| 2 | +using OpenQA.Selenium; |
| 3 | +using SeleniumWebdriver.ComponentHelper; |
| 4 | +using SeleniumWebdriver.Settings; |
| 5 | +using System; |
| 6 | +using System.Collections.Generic; |
| 7 | +using System.Linq; |
| 8 | +using System.Text; |
| 9 | +using System.Threading.Tasks; |
| 10 | + |
| 11 | +namespace SeleniumWebdriver.TestScript.Question |
| 12 | +{ |
| 13 | + [TestClass] |
| 14 | + public class TestGetDataFromPage |
| 15 | + { |
| 16 | + //Base xpath for the grid |
| 17 | + private const string BaseXpathOfGrid = "//div[@id='approved']//div[@class='durandal-wrapper']//ol[@class='contentList medium ui-sortable']"; |
| 18 | + |
| 19 | + [TestInitialize] |
| 20 | + public void TestSetup() |
| 21 | + { |
| 22 | + NavigationHelper.NavigateToUrl("https://internal.mem.com/sso/v2/internal"); |
| 23 | + GenericHelper.WaitForWebElementVisisble(By.Id("UserName"), TimeSpan.FromSeconds(60)); |
| 24 | + TextBoxHelper.TypeInTextBox(By.Id("UserName"), "AutoTester"); |
| 25 | + TextBoxHelper.TypeInTextBox(By.Id("Password"), "AutoTester123"); |
| 26 | + ButtonHelper.ClickButton(By.XPath("//span[text()='LOGIN']")); |
| 27 | + GenericHelper.WaitForWebElementVisisble(By.XPath("//label[text()='MeM Internal']"), TimeSpan.FromSeconds(70)); |
| 28 | + ButtonHelper.ClickButton(By.XPath("//label[text()='MeM Internal']")); |
| 29 | + } |
| 30 | + |
| 31 | + [TestMethod] |
| 32 | + public void TestGetData() |
| 33 | + { |
| 34 | + NavigationHelper.NavigateToUrl("https://admin.mem.com/sso/newde/7851114#contententry/condolences"); |
| 35 | + GenericHelper.WaitForWebElementVisisble(By.XPath(BaseXpathOfGrid), TimeSpan.FromSeconds(70)); |
| 36 | + var index = 2; // index for the item in un-ordered list |
| 37 | + while(GenericHelper.IsElemetPresent(By.XPath(BaseXpathOfGrid + "//li[" + index + "]"))) // To check if there are more item present |
| 38 | + { |
| 39 | + IWebElement heading = ObjectRepository.Driver.FindElement(By.XPath(BaseXpathOfGrid + "//li[" + index + "]//section//div[@class='thumbview']//div[@class='heading']")); // xpath of heading using index 2 -for 1st li , 3 - 2nd li... |
| 40 | + Console.WriteLine(heading.Text); |
| 41 | + heading = ObjectRepository.Driver.FindElement(By.XPath(BaseXpathOfGrid + "//li[" + index + "]//section//div[@class='thumbview']//div[@class='text']")); // xpath of description using index 2 -for 1st li , 3 - 2nd li... |
| 42 | + Console.WriteLine(heading.Text); |
| 43 | + index = index + 1; |
| 44 | + } |
| 45 | + } |
| 46 | + |
| 47 | + } |
| 48 | +} |
0 commit comments