Skip to content

Commit

Permalink
expand the solution:
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Sep 6, 2024
1 parent 817cb75 commit 4a5e5c5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions docs/recipes/parse-account-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,22 @@ Or if we need the account number text:
cy.get('#acc').invoke('text').should('equal', '056256265')
```

If you do not know the expected account number, you could use a regular expression

```js
cy.contains('#acc', /[0-9]{9}/)
```

You can confirm the initial text "..." disappears and the account pattern is present instead

```js
cy.get('#acc')
.should('not.have.text', '...')
.invoke('text')
.should('match', /^[0-9]{9}$/)
.then((account) => {
cy.log(`account ${account}`)
})
```

<!-- fiddle-end -->

0 comments on commit 4a5e5c5

Please sign in to comment.