Last active
February 4, 2019 17:43
-
-
Save kyk4322/66b2356d24629484c460fe2e2f1fe50a 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 | |
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(); | |
} |
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
<a href="#" aria-label="Go to the last page" title="Go to the last page" class="k-link k-pager-nav k-pager-last" data-page="3" tabindex="-1"><span class="k-icon k-i-arrow-end-right"></span></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment