Skip to content

Commit

Permalink
Merge pull request #4405 from wix/docs/fix-brackets
Browse files Browse the repository at this point in the history
docs(webviews): fix brackets position in API example, improve guide.
  • Loading branch information
asafkorem authored Mar 13, 2024
2 parents 786ece5 + 1acf814 commit efc091b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docs/api/webviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ This matcher is available for iOS only. See [this GitHub issue](https://github.c
If you have multiple web views on the screen and you want to interact with a specific web view, you can use the `atIndex()` method to choose the web view at the specified index.

```js
const myWebView = web(by.id('webview_identifier').atIndex(1));
const myWebView = web(by.id('webview_identifier')).atIndex(1);
const innerElement = myWebView.element(by.web.id('inner_element_identifier'));
await expect(innerElement).toHaveText('Hello World!');
```
Expand Down Expand Up @@ -146,7 +146,7 @@ web.element(by.web.tag('h1'));
Choose the element at the specified index.

```js
web.element(by.web.tag('h1').atIndex(1));
web.element(by.web.tag('h1')).atIndex(1);
```

Use it sparingly for those rare cases when you cannot make your matcher less ambiguous, so it returns one element only.
Expand Down
14 changes: 14 additions & 0 deletions docs/guide/testing-webviews.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,22 @@ const textElement = web(by.id('webview_identifier')).element(by.web.id('text_ele
const fontSize = await textElement.runScript(function get(element) {
return element.style.fontSize;
});

// Use jestExpect to assert the font size
jestExpect(fontSize).toBe('16px');
```

:::note

Using jest-expectations in Detox tests is possible by importing `expect` API from `jest` package and using it with a separate `jestExpect` variable (as shown in the example below).
This is due to the fact that Detox uses its own `expect` API, which is not compatible with jest-expectations.

```javascript
const jestExpect = require('expect').default;
```

:::

## Step 4: Assert on Expected Behaviour

Expectations are assertions on the state of elements within a WebView.
Expand Down

0 comments on commit efc091b

Please sign in to comment.