Selecting a row in a Kendo UI Grid using cypress - kendo-grid

I am using Cypress to test an application that uses Kendo Grid.
I have successfully using the following code to select the first record in the grid:
cy.get('#equiptmentGrid').invoke('getKendoGrid').invoke("select", 'tr:eq(0)')
Is there a way to select the last record in the Kendo Grid

Try using last() command from cypress. In the below example I have a kendo grid displaying records displaying in the Grid. The below test code will get the last tr then using find() command, find the tdand get the "Some Text" as below;
cy.get('#grid > div > table > tbody >tr').last().find('td').invoke("text").should('include', 'Some Text');
If could you please post the html, I will try to figure the way to get the last record

Related

How to mark checked for the values that are recievd from api into checkbox in VUEJS

I am learning VUEJS recently. I cannot move further as i am stuck in an issue.
ISSUE:
i am getting a list from an api call.
Here is the section of code for this:
<b-form-checkbox-group
v-model="authorize"
:options="authorize"
name="authorize"
stacked
text-field="name"
value-field="id"
>
I am getting this using .get('/authorize') and i have these values:
[{"id":"country:list","name":"country:list"},{"id":"country:create","name":"country:create"},{"id":"user:retrieve","name":"user:retrieve"},{"id":"user:update","name":"country:update"},{"id":"country:destroy","name":"user:destroy"}]
In another form i have added some of these value and in response, i get these values
[{"id":"country:list","name":"country:list"},{"id":"country:create","name":"country:create"},{"id":"user:retrieve","name":"user:retrieve"}]
i get these response using this:
<b-form-checkbox-group
v-model="authorize"
:options="currentTutorial.authorize"
name="authorize"
stacked
text-field="name"
value-field="id"
>
But what i want now is that i want to display all the authorize list along with the save items but those saved items should be checked which i am getting from currentTutorial.authorize here
Appreciate your help. thank you
<b-form-checkbox-group
v-model="authorize.id"
:options="authorize"
name="authorize"
stacked
text-field="name"
value-field="id"
>
can you change v-model variable liked as this

Why this XPathExpression 'div[#class="jobsearch-SerpJobCard unifiedRow row result clickcard"]' is not working?

I am developing a crawler with indeed.com. When I implement the xpath finding the path didn't work. Here is my expression tested in the chrome developer console. The result only returns an empty list.
$x('div[#class="jobsearch-SerpJobCard unifiedRow row result clickcard"]')
And here is the original HTML code.
I want to crawl the things inside the clickcard
I am confused about how to fix this problem
You have to use the following XPath in Scrapy to output the desired list of elements (remove the clickard part) :
response.xpath('//div[#class="jobsearch-SerpJobCard unifiedRow row result"]').getall()
Always check what Scrapy returns to you (HTML code in response) before applying your XPath expression.
Output for the following link : 18 elements.
In the JS console of your browser you have to input :
$x("//div[#class='jobsearch-SerpJobCard unifiedRow row result clickcard']")

Is there a way to access the first element in a column on a website using VBA?

Here is a screenshot of a column in a website page.
It is located in that way in the website page :
As you can see, all the rows have a 'Completed' button you can pres and followed by a number of lines. These rows refer to exports. So the columnis not static and is constantly changing.
However, everytime i run the macro i want to access the first row of the column.
Here is a sample code of he HTML code of the first 'Completed' button in the screenshot above:
I have many that have the same class name. Look at the highlighted rows as an example in the picture below:
I really have no idea how to write a VBA code to always access the first 'Completed' bytton in this column.
PS: In the HTML code, in the tag "a", the onclick="....." is constantly changing. So i cannot use this as an argument to access the desired field and click on the desired button.
Please if anyone could help me figure out how to do this, i would really be happy.
Thank you :)
If you want to click the 'Completed' button in the first column, you can use the code below:
Set doc = objIE.Document
doc.getElementsByTagName("tr")(0).getElementsByTagName("td")(0).getElementsByTagName("a")(0).Click
The code get the first <tr> then get the first <td> then get <a> in it.
<tr> tags are rows, <td> tags are cells inside those rows. You did not provide enough code to show the entire table, but generally speaking to access the first row of a table, you would need to refer to the collection object and use the index number you want.
.getElementsByTagName("tr")(0)
This will refer to the first row of a table. Same with getting the first column in the first row of your table:
.getElementsByTagName("tr")(0).getElementsByTagName("td")(0)
Once you tracked down the particular cell, now you are wanting to click the link. You can use the same method as above.
.getElementsByTagName("tr")(0).getElementsByTagName("td")(0).getElementsByTagName("a")(0).Click
And a final note, the first row of a table could be a header, so you may actually want the 2nd row (1) instead.
Thanks for updating with more HTML code. I am going to slightly switch gears and use querySelector() to grab the main table.
doc.querySelector("#divPage > table.advancedSearch_table > tbody"). _
getElementsByTagName("tr")(3).getElementsByTagName("td")(3).Children(0).Click
See if this works for you.

Xpath not getting content

I've tried looking through a bunch of answers already related to this, but I'm very unfamiliar with xpath and I'm a bit stuck.
I'm trying to just grab some information from a website, but I keep getting "imported content is empty" when i try to use importxml in excel.
Here's an example of the page I'm trying to read from (it's a college football simulator for running games. This call is Alabama vs Oklahoma using the 2019 teams):
http://www.ncaagamesim.com/FB_GameSimulator.asp?HomeTeam=Alabama&HomeYear=2019&AwayTeam=Oklahoma&AwayYear=2019&hs=1&hSchedule=0
I'm trying to grab the two teams' scores from the above link.
The first team's score's xpath is supposedly /html/body/div[3]/div/div/div[2]/div/div[1]/center/div[3]/div[1]/table/tbody/tr[1]/td[2]
but I keep getting an empty response.
I'm trying to use importxml in google sheets to get the data.
This returns quite a bit, but it doesn't appear to have the info I need. =importxml("http://www.ncaagamesim.com/FB_GameSimulator.asp?HomeTeam=Alabama&HomeYear=2019&AwayTeam=Oklahoma&AwayYear=2019&hs=1&hSchedule=0", "//div[contains(#class,gs_score)]")
If I quote the gs_score, it doesn't return anything.
Would appreciate any help with this. Thanks!
Edit: The xpath fails with /html/body/div[3]. If I change this to div[2], it returns some of the page data, but not the part I'm looking for.
According to an article I found -
Unfortunately, ImportXML doesn’t load JavaScript, so you won’t be able
to use this function if the content of the document is generated by
JavaScript (jQuery, etc.)
Not sure if this is relevant...
Edit 2:
I noticed the values I need are in an html table, so I tried using this
=IMPORTHTML("http://www.ncaagamesim.com/FB_GameSimulator.asp?HomeTeam=Alabama&HomeYear=2019&AwayTeam=Oklahoma&AwayYear=2019&hs=1&hSchedule=0", "table",1)
I'm still getting no content, no matter what table number I put in that formula.
If I copy the selector in the inspector, we get:
body > div.container > div > div > div.container > div > div.col-lg-9 > center > div:nth-child(3) > div.col-sm-6.col-xs-12.gs_score.gs_borderright.rightalign > table > tbody > tr:nth-child(1) > td:nth-child(2)
Which seems to be the same as the xpath.
Part of the answer: 'gs_score' needs to be in quotes - it's a string literal, not an element name. As an element name, it selects nothing, and everything contains nothing, so the predicate is always true.

Kendo grid retrieves old data when grouping

I am using a Kendo grid with grouping that displays some strange behavior if the grid is re-populated.
Steps to produce odd behavior:
On button click grid is created with data source but not data
One or more ajax calls are made and results are added to the grid
Data is rendered to the grid as expected
Click search button again and grid is populated as expected
Drag a column into the grouping bar
After step five, the grid is grouped with the original search data.
Click the group button to sort and the updated search is displayed.
Here is the code that adds rows to the grid:
var grid = $('#grid');
var dataSource = grid.data().kendoGrid.dataSource;
if (data.length > 0) {
$.each(data, function (i, v) {
dataSource.add(v);
});
}
I have tried several things to clear out the data source, including variations on the following:
$("#grid").data("kendoGrid").dataSource.data([ ]);
The old search data is retained somewhere and is not displayed until I starting grouping.
The resolution is clearing data from the grid itself and not the data source.
Calling the destroy method cleaned out all JQuery data attributes and I was able to repopulate the grid with the odd behavior.
var grid = $('#report').data('kendoGrid');
if (grid) {
grid.destroy();
}