Kendo UI grid select row via Selenium web driver


Mark Jones

I'm trying to write UI tests for an application that uses Kendo Grid. I'm using selenium to drive a browser and I'm having trouble selecting a row in the grid.

I've been able to select the correct row as follows:

IWebElement matterToSelect = MatterToSelectGrid.FindElement(By.XPath("//td[text()='" + matterId + "']/ancestor::tr"));

I was hoping to just use .click() for the webElement, but that didn't work. So I try to build an action:

new Actions(Driver).MoveToElement(matterToSelect).Click().Build().Perform();

There is no joy either. ok, how to select it using js?

IJavaScriptExecutor js = Driver as IJavaScriptExecutor;
js.ExecuteScript("return $(\"tr[data-uid='" + id + "']\").trigger('click');");

Or get nothing, just see if it works and which one to choose?

js.ExecuteScript("return $(\"#sourceGrid > table:nth-child(1) > tbody:nth-child(3) > tr:nth-child(1) > td:nth-child(1)\").click();");

grrrr still no luck. So my next thought maybe is that the kendo grid has a select() method that can be used? Well, seems good, but from what I've read, I also need to rebind the grid? All odd images I can find look like this:

$("#sourceGrid").data("kendoGrid").select()

But I don't want to rebind the grid from testing, so I haven't tried it. Also, I'm not sure what should be in data(), since all grids are setup using Html helper methods and bound to action methods using the .dataSource method. Does anyone have a better suggestion?

Mark Jones

OK, here's what I ended up doing:

IJavaScriptExecutor js = Driver as IJavaScriptExecutor;
            js.ExecuteScript(String.Format("return $('td:contains(\"{0}\")').parent().addClass('k-state-selected');", matterId));

Related


Kendo UI grid select row via Selenium web driver

Mark Jones I'm trying to write UI tests for an application that uses Kendo Grid. I'm using selenium to drive a browser and I'm having trouble selecting a row in the grid. I've been able to select the correct row as follows: IWebElement matterToSelect = MatterT

How to select items on <select> tag via Selenium web driver?

Testers from A3rdWorldCountry Before posting this, I've thoroughly researched all possible syntaxes to no avail. The closest I've come is with this code, where the dropdown actually appears, but the option I want isn't selected: new WebDriverWait(driver,10).un

How to select items on <select> tag via Selenium web driver?

Testers from A3rdWorldCountry Before posting this, I've thoroughly researched all possible syntaxes to no avail. The closest I've come is with this code, where the dropdown actually appears, but the option I want isn't selected: new WebDriverWait(driver,10).un

Programmatically select kendo grid row

kat1330: I found posts with similar titles but still can't solve the problem. I'm definitely doing it wrong. In the Kendo grid configuration there are some functions that can get the context (grid) and read the selected row: change: function (e) {

Programmatically select kendo grid row

kat1330: I found posts with similar titles but still can't solve the problem. I'm definitely doing it wrong. In the Kendo grid configuration there are some functions that can get the context (grid) and read the selected row: change: function (e) {

Automatically select a row in the kendo grid

ga016556 I have a kendo grid where when a row is clicked a detail grid is created for each row. Each row in the main grid has a column such as the user's LifeTimeId. After the grid is loaded, is it possible to automatically select the row with a specific LifeT

Programmatically select kendo grid row

kat1330: I found posts with similar titles but still can't solve the problem. I'm definitely doing it wrong. In the Kendo grid configuration there are some functions that can get the context (grid) and read the selected row: change: function (e) {

Automatically select a row in the kendo grid

ga016556 I have a kendo grid where when a row is clicked a detail grid is created for each row. Each row in the main grid has a column such as the user's LifeTimeId. After the grid is loaded, is it possible to automatically select the row with a specific LifeT

Kendo UI grid get row value

uiuxhub I'm trying to get the row item's value (name, email, age), but I'm only using the code below to get the first item. How can I get other lines of text by changing the tr:eq(1) code, or is there any other way to get the values of both items.

How to get a row in Kendo UI TreeList/Grid?

struggle is real I have a list of kendo trees in which I search for the row myDataItem(with the help of uid or value). When I execute: $("#treeList tbody").on("click", "tr", function (e) { var rSelectedRow = $(this); var getSelect = treeList.se

Kendo UI Grid get row id in ClientTemplate

Dortimer I have a custom template for a column in a KendoUI grid and I need to get the ID of the row so I can pass it to a Javascript function. I should note that in the ClientTemplate I have some Url.Actions that access the ID using "#=Id#", but for some reas

Kendo UI MVC grid row selection

Paul I need to do a "history" push state to perform some "grid click" action. I looked at the API and I think the activity changes the correct position... So, this is the code I'm going to put in there "window.History.pushState(null, null," + "'" + Url.Action(

Kendo ui Grid row undo delete

Jagath Jayasinghe I don't delete when there is only one row in the grid. However, when the grid is in inline edit mode, when I click the grid row delete button, it deletes the row from the grid, but not when I don't actually delete the row from the server grid

Kendo UI grid highlight selected row

Kelly Cline I have a Kendo (2013.2.716) grid with an Edit command (the edit button is in the first column) and 40+ other columns. I didn't set Selectable for grid. After filling the grid, I can move the mouse down to the Edit command column and highlight each

Kendo UI grid get row value

uiuxhub I'm trying to get the row item's value (name, email, age), but I'm only using the code below to get the first item. How can I get other lines of text by changing the tr:eq(1) code, or is there any other way to get the values of both items.

Kendo UI Grid repost inserted row

new high school I'm having a problem, when the insert is successfully done and if I go ahead and insert another row, on the next insert it also sends the row that was successfully inserted before, so it goes like this. On the "first insert", the row is posted

Unable to style first row in Kendo UI grid

Peaceful Thought I want to style rows in kendo ui grid. Here is my code: //grid @(Html.Kendo().Grid<Model>() .Name("gridModel") .HtmlAttributes(new { @class = "table" }) .DataSource(x => x.Ajax() .Read("ReadD

Kendo UI grid row height on initialization

square I am using Kendo UI grid in my project to display my data. I'm having trouble with its row height. When the grid is initialized; the line seems odd. I am trying to provide some information about the back of the grid. The console screen contains some inf

Kendo UI Grid get row id in ClientTemplate

Dortimer I have a custom template for a column in a KendoUI grid and I need to get the ID of the row so I can pass it to a Javascript function. I should note that in the ClientTemplate I have some Url.Actions that access the ID using "#=Id#", but for some reas

Kendo UI Grid Row Template Commands

Ashshri I have requirement in KendoUI Grid where I have first column as Command template checkbox, so onclickwhen event occurs I want to get value and id of all columns of same selected row. Below is the column part of my grid columns: [

Kendo UI MVC grid row selection

Paul I need to do a "history" push state to perform some "grid click" action. I looked at the API and I think the activity changes the correct position... So, this is the code I'm going to put in there "window.History.pushState(null, null," + "'" + Url.Action(

Kendo UI grid get row value

uiuxhub I'm trying to get the value of a row item (name, email, age), but I'm only using the code below to get the first item. How can I get other lines of text by changing the tr:eq(1) code, or is there any other way to get the values of both items.

Kendo ui Grid row undo delete

Jagath Jayasinghe I don't delete when there is only one row in the grid. However, when the grid is in inline edit mode, when I click the grid row delete button, it deletes the row from the grid, but not when I don't actually delete the row from the server grid

Kendo UI grid row height on initialization

square I am using Kendo UI grid in my project to display my data. I'm having trouble with its row height. When the grid is initialized; the line seems odd. I am trying to provide some information about the back of the grid. The console screen contains some inf