Skip to content

Commit

Permalink
Fiz nth
Browse files Browse the repository at this point in the history
  • Loading branch information
JaySunSyn committed May 3, 2019
1 parent ed16ff3 commit 7423983
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ Cypress.Commands.overwrite('get', (originalFn, selector, options) => {

return cy.window({log: false}).then((w) => new Cypress.Promise((resolve, reject) => {
const walker = new Daywalker(w);

const result = options && options.all
? walker.querySelectorAll(selector)
: walker.querySelector(selector, (options && options.nth) || 0);
: walker.querySelector(selector, (options && options.nth) || 1);
if (result != null) {
resolve(result);
return true;
Expand Down
4 changes: 2 additions & 2 deletions daywalker-store-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ class DaywalkerStoreQuery {
return result;
}

querySelector(selector, nth = 0) {
querySelector(selector, nth = 1) {
const result = this.queryStore(selector);
if (Array.isArray(result)) {
return result.length > nth ? result[nth] : null;
return result.length >= nth ? result[nth - 1] : null;
}
return result;
}
Expand Down

0 comments on commit 7423983

Please sign in to comment.