Skip to content

Commit

Permalink
feat: add getText command
Browse files Browse the repository at this point in the history
Signed-off-by: Jakub Mucha <[email protected]>
  • Loading branch information
drptbl committed Dec 1, 2020
1 parent 86d400e commit 4870521
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Cypress.Commands.add('getId', name => {
}
return cy.get(`[data-testid="${name}"]`).as(name);
});

Cypress.Commands.add('getText', selector => {
return cy.getId(`${selector}`).invoke('text');
});

Cypress.Commands.add('getDesktopSizes', () => {
return [
[1366, 768],
Expand Down
7 changes: 7 additions & 0 deletions support/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ declare namespace Cypress {
* cy.getId('alias')
*/
getId(testid: string): Chainable<Subject>;
/**
* Get text of element
* @example
* cy.getText('selector').then(text => cy.log(text))
* cy.getText('alias').then(text => cy.log(text))
*/
getText(selector: string): Chainable<Subject>;
/**
* Get the most popular desktop resolutions
* @example
Expand Down

0 comments on commit 4870521

Please sign in to comment.