Skip to content

Commit

Permalink
Fix incorrect formatting of code in FAQ question
Browse files Browse the repository at this point in the history
  • Loading branch information
jennifer-shehane committed Mar 6, 2020
1 parent 33ceda2 commit 01d0f40
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions source/faq/questions/using-cypress-faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -607,14 +607,12 @@ cy.get('@consoleLog').should('be.calledWith', 'Hello World!')

Also, check out our {% url 'Stubbing `console` Receipe' recipes#Stubbing-and-spying %}.

## {% fa fa-angle-right %} How do I use special characters with cy.get?
## {% fa fa-angle-right %} How do I use special characters with `cy.get()`?

{% url "According to the CSS spec" https://www.w3.org/TR/html50/dom.html#the-id-attribute %}, special characters like `/`, `.` are valid characters for ids.
Special characters like `/`, `.` are valid characters for ids {% url "according to the CSS spec" https://www.w3.org/TR/html50/dom.html#the-id-attribute %}.

To test elements with those characters in ids, they need to be escaped with {% url "`CSS.escape`" https://developer.mozilla.org/en-US/docs/Web/API/CSS/escape %} or {% url "`Cypress.$.escapeSelector`" https://api.jquery.com/jQuery.escapeSelector/ %}.

Example:

```html
<!doctype html>
<html lang="en">
Expand All @@ -627,8 +625,11 @@ Example:
```js
it('test', () => {
cy.visit('index.html')
cy.get(`#${CSS.escape('Configuration/Setup/TextField.id')}`).contains('Hello World')
cy.get(`#${Cypress.$.escapeSelector('Configuration/Setup/TextField.id')}`).contains('Hello World')
cy.get(`#${CSS.escape('Configuration/Setup/TextField.id')}`)
.contains('Hello World')

cy.get(`#${Cypress.$.escapeSelector('Configuration/Setup/TextField.id')}`)
.contains('Hello World')
})
```

Expand Down

0 comments on commit 01d0f40

Please sign in to comment.