Skip to content

Commit 433d3f9

Browse files
[docs] Transfer examples from testcafe-examples (DevExpress#5585)
* Transfer examples from the testcafe-examples repo per Mikhail's request * Address Mikhail's remarks
1 parent f407d78 commit 433d3f9

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

‎docs/articles/documentation/guides/basic-guides/obtain-client-side-info.md‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,27 @@ test('My Test', async t => {
7070
});
7171
```
7272

73+
### Pass Parameters to Client Functions
74+
75+
This example shows the `getLocationPart` client function that returns a [Location](https://developer.mozilla.org/en-US/docs/Web/API/Location) property value. The property name is passed as the `locationPart` parameter.
76+
77+
```js
78+
import { ClientFunction } from 'testcafe';
79+
80+
fixture `Parameterized Client Functions`
81+
.page('https://devexpress.github.io/testcafe/example/');
82+
83+
const getLocationPart = ClientFunction(locationPart => {
84+
return window.location[locationPart];
85+
});
86+
87+
test('Parameterized Client Functions', async t => {
88+
await t
89+
.expect(getLocationPart('host')).eql('devexpress.github.io')
90+
.expect(getLocationPart('pathname')).eql('/testcafe/example/');
91+
});
92+
```
93+
7394
## Overwrite Client Function Options
7495

7596
Overwrite client function options via the ClientFunction's [with](../../reference/test-api/clientfunction/with.md) method.

‎docs/articles/documentation/reference/test-api/testcontroller/switchtoiframe.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ test('switching to an iframe', async t => {
4141

4242
You can switch to the main window from the `<iframe>` with the [t.switchToMainWindow](switchtomainwindow.md) method.
4343

44+
## Wait Until an \<iframe\> Is Loaded
45+
46+
TestCafe implements [wait mechanisms](../../../guides/concepts/built-in-wait-mechanisms.md) that automatically suspend the test until all required page elements are loaded and ready for interaction. These mechanisms apply to page loads, animations, XHR requests, iframe initializations, etc. TestCafe waits until the target element is ready, or reports an error if this does not happen within a timeout.
47+
48+
This example shows how to allow more time for an `iframe` to load if the [default timeout](../../command-line-interface.md#--selector-timeout-ms) is not enough.
49+
50+
```js
51+
fixture `Wait for an iframe to load`
52+
.page `https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/Overview/jQuery/Light/`;
53+
54+
test('Wait for an iframe to load', async t => {
55+
const iframeSelector = Selector('#demoFrame', { timeout: 60000 });
56+
57+
await t.switchToIframe(iframeSelector);
58+
});
59+
```
60+
61+
In this example, the [timeout](../selector/constructor.md#optionstimeout) in the [Selector constructor](../selector/constructor.md) options is set to `60` seconds so that the `iframe` has one minute to initialize.
62+
4463
## Select Target Elements
4564

4665
{% include actions/selector-parameter.md %}

0 commit comments

Comments
 (0)