-
-
Save jimevans/88e7a3d0cb7bd5c6879aaca96d048681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DataTable dt = new DataTable(); | |
var header = driver.FindElement(By.CssSelector("#gridComponent > div.k-grid-header")); | |
foreach (var row in header.FindElements(By.TagName("tr"))) | |
{ | |
//Configure Number of Col and row | |
int cellIndex = 0; | |
string[] arr = new string[32]; | |
//Get Cell Data | |
foreach (var cell in row.FindElements(By.TagName("th"))) | |
{ | |
// Check the header cell for a checkbox child. If no | |
// such child exists, add the column. | |
var headerCheckboxes = cell.FindElements(By.CssSelector("input[type='checkbox']")); | |
if (headerCheckboxes.Count == 0) | |
{ | |
//Number of Col Data Load | |
if (cellIndex <= 29) | |
{ | |
arr[cellIndex] = cell.Text; | |
dt.Columns.Add(cell.Text); | |
} | |
else | |
continue; | |
cellIndex++; | |
} | |
} | |
Console.WriteLine(arr); | |
} | |
var table = driver.FindElement(By.CssSelector("#gridComponent")); | |
//Get Row value | |
foreach (var row in table.FindElements(By.TagName("tr"))) | |
{ | |
//Configure Number of Col and row | |
int cellIndex = 0; | |
// Use a list instead of an array | |
List<string> arr = new List<string>(); | |
//Get Cell Data | |
foreach (var cell in row.FindElements(By.TagName("td"))) | |
{ | |
// Skip the first column in the row by checking | |
// if the cell index is 0. | |
if (cellIndex != 0) | |
{ | |
string cellValue = ""; | |
Console.WriteLine(cell); | |
var checkboxes = cell.FindElements(By.CssSelector("input[type='checkbox']")); | |
if (checkboxes.Count > 0) | |
{ | |
bool isChecked = false; | |
isChecked = checkboxes[0].Selected; | |
cellValue = isChecked.ToString(); | |
} | |
else | |
{ | |
cellValue = cell.Text; | |
} | |
arr.Add(cellValue); | |
} | |
cellIndex++; | |
} | |
dt.Rows.Add(arr.ToArray()); | |
} | |
dataGridView1.DataSource = dt; | |
driver.FindElement(By.CssSelector("#gridComponent > div.k-pager-wrap.k-grid-pager.k-widget.k-floatwrap > ul > li:nth-child(3)")).Click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment