Skip to content

Commit 0a007a6

Browse files
rathr1rathr1
authored andcommitted
Extract text
1 parent 9851c7d commit 0a007a6

3 files changed

Lines changed: 87 additions & 0 deletions

File tree

SeleniumWebdriver/SeleniumWebdriver.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,8 @@
173173
<Compile Include="TestScript\Popups\TestPopups.cs" />
174174
<Compile Include="TestScript\Question\SubString.cs" />
175175
<Compile Include="TestScript\Question\TestFileDownload.cs" />
176+
<Compile Include="TestScript\Question\TestGetDataFromPage.cs" />
177+
<Compile Include="TestScript\Question\TestReadExcelFile.cs" />
176178
<Compile Include="TestScript\RadAutoCompleteBox\TC-AutoSuggestComboBox.cs" />
177179
<Compile Include="TestScript\RadioButton\HandleRadioButton.cs" />
178180
<Compile Include="TestScript\ScreenShot\TakeScreenShots.cs" />
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using ExcelDataReader;
2+
using Microsoft.VisualStudio.TestTools.UnitTesting;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Data;
6+
using System.IO;
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 TestReadExcelFile
15+
{
16+
[TestMethod]
17+
public void TestReadExcel()
18+
{
19+
FileStream stream = new FileStream(@"C:\Users\rathr1\Desktop\KDD.xlsx", FileMode.Open, FileAccess.Read);
20+
IExcelDataReader reader = ExcelReaderFactory.CreateOpenXmlReader(stream);
21+
DataTable table = reader.AsDataSet().Tables["TC01"];
22+
23+
for(int i = 0; i < table.Rows.Count; i++)
24+
{
25+
var col = table.Rows[i];
26+
for(int j = 0; j < col.ItemArray.Length; j++)
27+
{
28+
Console.WriteLine(col.ItemArray[j]);
29+
}
30+
}
31+
32+
reader.Close();
33+
stream.Close();
34+
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)