Query URL - "XYZ "
From the above URL we can see different category's like a, b & c.
Now, my question is how we can get the length present in each category and display in the output?
For example c has 13 count listed, This I want to show case using cypress code.
You can iterate over the tab sections using each(), perform a click, and then calculate the length of all the questions. A simple program demonstrating that -
it('Print the Number of Questions in each Tab', function() {
cy.visit('https://www.kreditbee.in/faq')
cy.get('button[role="tab"]').each(($ele) => {
cy.wrap($ele).click()
cy.get('svg').its('length').then((len) => {
cy.log('The number of questions in ' + $ele.text() + ' tab: ' + len)
})
})
})
Related
I wanted to build a custom-filter for my v-data-table (containing books) which
allows to narrow down search results by entering multiple space separated search terms
separates compound words with hyphens into separate search terms
all search terms should appear in the item, but they can appear in different columns/props, so searching for "tolkien hobbit" would give you back a book with title "The Hobbit" and author "J.R.R. Tolkien"
I figured that using "value" in the customFilter function would require all of the search terms to appear in the same prop, so I used item instead, but vuetify gives the complete item to the filter function, not only the filterable headers of the data table, which will yield unwanted search results, so I'm re-initializing the item to get rid of unwanted props.
methods: {
customFilter(value, search, item) {
item = {
number: item.number,
title: item.title,
author: item.author
};
const haystack = Object.values(item).join().toLowerCase();
let s = search.toString().toLowerCase();
let needles = s.replace('-',' ').split(' ');
return needles.filter(needle => haystack.indexOf(needle) >= 0).length == needles.length
}
}
My questions
Is there a way to tell vuetify to only give the filterable header props to the custom-filter as item?
if not, is there a better way to get rid of unwanted props than re-initializing? (destructuring with spread operator also works, but is longer and eslint nags about unused vars)
Is there maybe even a way to realize my requirements with "value" instead of "item"? (I don't see how)
Answering my own questions:
No, you can't tell vuetify to pass only specific props of the item to the custom filter, you just pass the item object
I get rid of unwanted props by filtering / reducing now
value only gives you one value, presumably it defaults to the first column, but I'm not 100% sure
My solution now:
methods: {
itemFilterMultipleSearchTermsAnd(value, search, item) {
const nonSearchableColumns = ["excludedPropName1", "excludedPropName2"];
const reducedObject = Object.keys(item)
.filter((key) => !nonSearchableColumns.includes(key))
.reduce((res, key) => ((res[key] = item[key]), res), {});
const haystack = Object.values(reducedObject)
.join()
.toLowerCase();
let s = search.toString().toLowerCase();
let needles = s.replace("-", " ").split(" ");
return (
needles.filter((needle) => haystack.indexOf(needle) >= 0).length ==
needles.length
);
}
}
i am using this code to pull google search result using =importxml formula.Column A and B is for result of importXML.
Column c is for url of goole search query and column D and E holds //h3[#class='r'] and //h3/a/#href.
Currently the code keeps overwriting the old data if i call the function multiple times.
What i want to check if xml elements dont exist in entire sheet then insert them to sheet?Is there away to acomplish this ?
Note:google search result returns 10 sets of data when it is called
function getData() {
var queryString = Math.random();
var cellFunction1 = '=IMPORTXML("' + SpreadsheetApp.getActiveSheet().getRange('C2').getValue() + '&randomNumber=' + queryString + '","'+ SpreadsheetApp.getActiveSheet().getRange('D2').getValue() + '")';
SpreadsheetApp.getActiveSheet().getRange('A2').setValue(cellFunction1);
var cellFunction2 = '=IMPORTXML("' + SpreadsheetApp.getActiveSheet().getRange('C2').getValue() + '&randomNumber=' + queryString + '","'+ SpreadsheetApp.getActiveSheet().getRange('E2').getValue() + '")';
SpreadsheetApp.getActiveSheet().getRange('B2').setValue(cellFunction2);
}
I'm writing a protractor test for angular code that adds an item to a list displayed with ng-repeat.
I want to check that when the user clicks a button, another item is added to the list within a few hundred milliseconds.
The initial count of items is unknown.
The test pseudocode is like this :
var e = element.all(by.repeater(...))
getButtonPromise().click() // -> XHR to server, which adds item to list
expect(e.count()).toBe(XXX)
Constraints :
1) the initial number of items must be measured BEFORE the click is executed
2) the expected value is (the initial value + 1)
3) expect(...) must be run periodically until timeout or list count has reached the expected value
4) the control flow for the rest of the test must be stopped until expect(...) resolves to success or timeout
I have tried various approaches but nothing works.
Your help in solving this common testing pattern is appreciated.
var e = element.all(by.repeater(...))
e.count().then(function(oldCount) {
getButtonPromise().click();
browser.wait(function() {
return e.count().then(function(newCount) {
return newCount === oldCount + 1;
})
}, YOUR_TIMEOUT_IN_MILLISECONDS);
expect(e.count()).toEqual(oldCount + 1); // this is optional because if this isn't true, it would have timed out already.
})
I read on many forums about how to implement a solution for view pagionation, but I didn't solve it.
I created $$ViewTemplateDefault containing some personalized hotspotbuttons for Next, Previous and a text field $$ViewBody. ( or, alternatively, an embedded view ).
Any tips and help will be really appreciated.
I will explain in a couple words, just to be clear:
So, initially: the first 30 lines will appear => in a right corner: Page 1.
If Next is clicked => the next 30 lines => Page 2. and so on.
Here is a working solution for categorized views too. It calculates the current page number based on the previous page number and uses cookies.
Add to your form a Path-Thru HTML text <span id="pageNumber"></span > for the page number:
and add following code to form's onLoad event as Web/JavaScript:
function getURLParameter(parameter) {
return decodeURIComponent((new RegExp('[?|&]' + parameter + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [, ""])[1].replace(/\+/g, '%20')) || null;
}
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
function compareStart(start1, start2) {
var list1 = start1.split(".");
var list2 = start2.split(".");
for (i=0; i <100; i++) {
var value1 = list1[i];
var value2 = list2[i];
if (value1 == null) {
return value2 == null ? 0 : -1;
} else if (value2 == null) {
return 1;
}
value1 = Math.round(value1);
value2 = Math.round(value2);
if (value1 !== value2) {
return value1 < value2 ? -1 : 1;
}
}
}
var start = getURLParameter("Start");
var page = "1";
if (start == null || start === "1") {
window.name = Math.floor((Math.random()*10000)+1);
start = "1";
} else {
page = getCookie("page" + window.name);
var oldStart = getCookie("start" + window.name);
page = Math.round(page) + compareStart(start, oldStart);
}
document.getElementById('pageNumber').innerHTML = page;
document.cookie = "page" + window.name + "=" + page;
document.cookie = "start" + window.name + "=" + start;
How does it work?
The commands #DbCommand("Domino"; "ViewNextPage") and #DbCommand("Domino"; "ViewPreviousPage") return an URL with parameter "&Start=". This is the row number in view where the current page starts. For categorized views they return a hierarchical number like "&Start=1.2.4.2". That means that the view starts at the first main topic, subtopic 2, subsubtopic 4, document 2.
This parameter "&Start=" gives us the possibility to recognize if user pressed "prev" or "next": we just compare the URL "&Start=" parameter of current and former page.
For that, we have to remember the URL "&Start=" parameter and put it into a cookie "start".
We also need to save the current page number. We put it into a cookie "page".
At onload event we calculate the current page number based on previous page number:
if "&Start=" parameter is larger now then we add 1
if "&Start=" parameter is smaller now then we subtract 1
if "&Start=" parameter didn't change then we keep the former value
If "&Start=" parameter is empty we know we are on page 1.
Here is one other thing we have to deal with: cookies are saved per user session not per browser tab. That means, if we have two views open in browser same cookies "start" and "page" would be used. To avoid that, we have to add to cookie name something tab specific. I use for that a random four digit number and save it in window.name which is tab specific.
I understand your question that you have a working form $$ViewTemplateDefault and now looking for a possibility to show the current page number "Page nn" in that form.
I assume that you use #DbCommand("Domino"; "ViewNextPage") for getting next page and #DbCommand("Domino"; "ViewPreviousPage") for getting previous page.
Those next and prev functions working the way that always one document will "overlap". If you have 30 lines per page and click next, then last document will be first in next page and next 29 show up in addition. You can watch that in used URL parameter "&Start=": 1 ... 30 ... 59 ... 88 ...
Knowing this you can count the current page number this way:
_start := #ToNumber(#Replace(#UrlQueryString("start"); ""; "1"));
_count := #ToNumber(#Replace(#UrlQueryString("count"); ""; "30")) - 1;
#Integer((#ToNumber(_start) / _count) + 1)
Be aware that this will work for non-categorized and non-collapsible views only.
A more sophisticated solution you can find here. It has additional features like GoTo page and Documents per page.
If you have the chance for your project then use XPages instead. You can do pagination much easier as it is available "out of the box".
Update:
You won't find a reasonable solution for categorized views. If you don't want to use Domino Data/Access Services REST API you have to live with the Domino view URL parameters (look here for "OpenView"). You aren't able to tell from "&Start=" or any other parameter on which page you are currently on.
The easiest way to get a good working pagination is using XPages. Hope you are allowed to use it in your project...
I have a grid that implements grouping but would like to expand on the details that display in the groupText: area. Ideally I would be able to take data about that grouping and display in that group row with the group name ({0} default value).
In other words what I am trying to achieve is a way to display not only the group name but also some other data items contained in the JSON feed to the grid.
My searching seems to be coming up short on anyone being able to achieve this but I'm hoping someone can shed some light on expanding this setting and providing access to formating this area.
I find your question interesting, but the implementation is not simple. In the answer I showed before how one could use custom formatter in summary rows of the grouping.
In the demo you can see how to implement custom formatting of the grouping text. The demo display the following:
The implementation consist just from the implementation of the custom formatter which can be used for both purpose: formatting of the content of the corresponding column and formatting of the grouping text in case of grouping by the column. The code is a little tricky, but I hope that all will be able follow it. The code use the differences of the input parameters to define whether the formatter will be called to format the column content or to format the grouping text.
One part of the code which get the texts like "(test4,test7)" is not so effective in case of the usage of large number of rows, but it works.
Below is the code of formatter of the "Date" column which would by typically used with the predefined formatter: 'date'. I called in the part of the code the original Date-formatter, but used for the the grouping text more sophisticated code:
formatter: function (cellval, opts, rowObject, action) {
var fullOpts = $.extend({}, $.jgrid.formatter.date, opts),
formattedDate = $.fmatter.util.DateFormat('Y-m-d', cellval, 'd-M-Y', fullOpts),
groupIdPrefix = opts.gid + "ghead_",
groupIdPrefixLength = groupIdPrefix.length,
month = Number(cellval.split('-')[1]), // input format 'Y-m-d'
names = [], data, i, l, item;
// test wether opts.rowId start with opts.gid + "ghead_" and integer
// and rowObject is the array and action is undefined.
if (opts.rowId.substr(0, groupIdPrefixLength) === groupIdPrefix && typeof action === "undefined") {
// custom formating of the group header
// we just simulate some login by testing of the month > 9
// the next code fragment is not effective, but it can be used
// in case of not so large number of groups and the local data
data = $(this).jqGrid("getGridParam", "data");
for (i = 0, l = data.length; i < l; i++) {
item = data[i];
if (item.invdate === cellval) {
names.push(item.name);
}
}
return (month > 9 ? ('<span class="ui-icon ui-icon-alert" style="float: left;"></span>' +
'<span style="color:tomato; margin-left: 5px;">') : "<span>") +
formattedDate + ' (' + names.join() + ')</span>'
}
return formattedDate;
}
UPDATED: The fixed version of the demo is here. It uses $.fn.fmatter instead of currently removed from jqGrid method $.fmatter.util.DateFormat.