{"action":"created","comment":{"url":"https://api.github.com/repos/DevExpress/testcafe/pulls/comments/172223219","pull_request_review_id":101198883,"id":172223219,"diff_hunk":"@@ -0,0 +1,174 @@\n+---\n+layout: docs\n+title: Examples of Using Client Functions\n+permalink: /documentation/test-api/obtaining-data-from-the-client/examples-of-using-client-functions.html\n+---\n+# Examples of Using Client Functions\n+\n+This topic contains some cases of using client functions in tests.\n+\n+* [Checking a Page URL](#checking-a-page-url)\n+* [Obtaining a Browser Alias Within a Test](#obtaining-a-browser-alias-within-a-test)\n+* [Injecting External Libraries into a Page from a Test](#injecting-external-libraries-into-a-page-from-a-test)\n+* [Accessing Child Nodes in the DOM Hierarchy](#accessing-child-nodes-in-the-dom-hierarchy)\n+* [Complex DOM Queries](#complex-dom-queries)\n+\n+## Checking a Page URL\n+\n+It is a typical situation when performing some actions on a tested web page (clicking buttons or links) redirects a browser to another page and you need to check whether a desired page is currently opened. For example, you test a login form of your web application and need to verify if a particular web page is opened after a user has logged in.\n+\n+To return the URL of a page that is currently opened on the client, you can create a client function and use the [window.location.href](https://www.w3schools.com/jsref/prop_loc_href.asp) property within it. Then you can verify if the actual page URL matches the expected one by using the `expect` assertion. The sample below demonstrates how to do this.\n+\n+```js\n+import { ClientFunction } from 'testcafe';\n+\n+fixture `My Fixture`\n+   .page `http://devexpress.github.io/testcafe/example`;\n+\n+//Returns the URL of the current web page\n+const getPageUrl = ClientFunction(() => window.location.href);\n+\n+test('Check the page URL', async t => {\n+   await t\n+       .typeText('#developer-name', 'John Smith')\n+       .click('#submit-button') // Redirects to the 'Thank you' page","path":"docs/articles/documentation/test-api/obtaining-data-from-the-client/examples-of-using-client-functions.md","position":34,"original_position":34,"commit_id":"72b5a123d8fbbd112e9fb6249dc72851b9a40e42","original_commit_id":"72b5a123d8fbbd112e9fb6249dc72851b9a40e42","user":{"login":"helen-dikareva","id":12034551,"avatar_url":"https://avatars1.githubusercontent.com/u/12034551?v=4","gravatar_id":"","url":"https://api.github.com/users/helen-dikareva","html_url":"https://github.com/helen-dikareva","followers_url":"https://api.github.com/users/helen-dikareva/followers","following_url":"https://api.github.com/users/helen-dikareva/following{/other_user}","gists_url":"https://api.github.com/users/helen-dikareva/gists{/gist_id}","starred_url":"https://api.github.com/users/helen-dikareva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/helen-dikareva/subscriptions","organizations_url":"https://api.github.com/users/helen-dikareva/orgs","repos_url":"https://api.github.com/users/helen-dikareva/repos","events_url":"https://api.github.com/users/helen-dikareva/events{/privacy}","received_events_url":"https://api.github.com/users/helen-dikareva/received_events","type":"User","site_admin":false},"body":"There is a space before the text after `//`. But there aren't in other comments. Let's make them consistent.","created_at":"2018-03-05T15:27:06Z","updated_at":"2018-03-05T16:03:00Z","html_url":"https://github.com/DevExpress/testcafe/pull/2193#discussion_r172223219","pull_request_url":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/DevExpress/testcafe/pulls/comments/172223219"},"html":{"href":"https://github.com/DevExpress/testcafe/pull/2193#discussion_r172223219"},"pull_request":{"href":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193"}}},"pull_request":{"url":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193","id":172847277,"html_url":"https://github.com/DevExpress/testcafe/pull/2193","diff_url":"https://github.com/DevExpress/testcafe/pull/2193.diff","patch_url":"https://github.com/DevExpress/testcafe/pull/2193.patch","issue_url":"https://api.github.com/repos/DevExpress/testcafe/issues/2193","number":2193,"state":"open","locked":false,"title":"[docs] New topic: Examples of Using Client Functions","user":{"login":"MargaritaLoseva","id":12034505,"avatar_url":"https://avatars2.githubusercontent.com/u/12034505?v=4","gravatar_id":"","url":"https://api.github.com/users/MargaritaLoseva","html_url":"https://github.com/MargaritaLoseva","followers_url":"https://api.github.com/users/MargaritaLoseva/followers","following_url":"https://api.github.com/users/MargaritaLoseva/following{/other_user}","gists_url":"https://api.github.com/users/MargaritaLoseva/gists{/gist_id}","starred_url":"https://api.github.com/users/MargaritaLoseva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MargaritaLoseva/subscriptions","organizations_url":"https://api.github.com/users/MargaritaLoseva/orgs","repos_url":"https://api.github.com/users/MargaritaLoseva/repos","events_url":"https://api.github.com/users/MargaritaLoseva/events{/privacy}","received_events_url":"https://api.github.com/users/MargaritaLoseva/received_events","type":"User","site_admin":false},"body":"//cc @DevExpress/testcafe Review only the _Examples of Using Client Functions.md_ file.\r\n\r\n#1977 ","created_at":"2018-03-05T11:57:22Z","updated_at":"2018-03-05T16:03:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"278246fa2b74282f5e9e66aa3c7124272abd016c","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193/commits","review_comments_url":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193/comments","review_comment_url":"https://api.github.com/repos/DevExpress/testcafe/pulls/comments{/number}","comments_url":"https://api.github.com/repos/DevExpress/testcafe/issues/2193/comments","statuses_url":"https://api.github.com/repos/DevExpress/testcafe/statuses/72b5a123d8fbbd112e9fb6249dc72851b9a40e42","head":{"label":"MargaritaLoseva:master","ref":"master","sha":"72b5a123d8fbbd112e9fb6249dc72851b9a40e42","user":{"login":"MargaritaLoseva","id":12034505,"avatar_url":"https://avatars2.githubusercontent.com/u/12034505?v=4","gravatar_id":"","url":"https://api.github.com/users/MargaritaLoseva","html_url":"https://github.com/MargaritaLoseva","followers_url":"https://api.github.com/users/MargaritaLoseva/followers","following_url":"https://api.github.com/users/MargaritaLoseva/following{/other_user}","gists_url":"https://api.github.com/users/MargaritaLoseva/gists{/gist_id}","starred_url":"https://api.github.com/users/MargaritaLoseva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MargaritaLoseva/subscriptions","organizations_url":"https://api.github.com/users/MargaritaLoseva/orgs","repos_url":"https://api.github.com/users/MargaritaLoseva/repos","events_url":"https://api.github.com/users/MargaritaLoseva/events{/privacy}","received_events_url":"https://api.github.com/users/MargaritaLoseva/received_events","type":"User","site_admin":false},"repo":{"id":50342524,"name":"testcafe","full_name":"MargaritaLoseva/testcafe","owner":{"login":"MargaritaLoseva","id":12034505,"avatar_url":"https://avatars2.githubusercontent.com/u/12034505?v=4","gravatar_id":"","url":"https://api.github.com/users/MargaritaLoseva","html_url":"https://github.com/MargaritaLoseva","followers_url":"https://api.github.com/users/MargaritaLoseva/followers","following_url":"https://api.github.com/users/MargaritaLoseva/following{/other_user}","gists_url":"https://api.github.com/users/MargaritaLoseva/gists{/gist_id}","starred_url":"https://api.github.com/users/MargaritaLoseva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MargaritaLoseva/subscriptions","organizations_url":"https://api.github.com/users/MargaritaLoseva/orgs","repos_url":"https://api.github.com/users/MargaritaLoseva/repos","events_url":"https://api.github.com/users/MargaritaLoseva/events{/privacy}","received_events_url":"https://api.github.com/users/MargaritaLoseva/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/MargaritaLoseva/testcafe","description":null,"fork":true,"url":"https://api.github.com/repos/MargaritaLoseva/testcafe","forks_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/forks","keys_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/teams","hooks_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/hooks","issue_events_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/issues/events{/number}","events_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/events","assignees_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/assignees{/user}","branches_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/branches{/branch}","tags_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/tags","blobs_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/git/refs{/sha}","trees_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/statuses/{sha}","languages_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/languages","stargazers_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/stargazers","contributors_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/contributors","subscribers_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/subscribers","subscription_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/subscription","commits_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/commits{/sha}","git_commits_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/git/commits{/sha}","comments_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/comments{/number}","issue_comment_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/issues/comments{/number}","contents_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/contents/{+path}","compare_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/merges","archive_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/downloads","issues_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/issues{/number}","pulls_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/pulls{/number}","milestones_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/milestones{/number}","notifications_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/labels{/name}","releases_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/releases{/id}","deployments_url":"https://api.github.com/repos/MargaritaLoseva/testcafe/deployments","created_at":"2016-01-25T10:12:58Z","updated_at":"2016-01-25T10:13:00Z","pushed_at":"2018-03-05T11:50:23Z","git_url":"git://github.com/MargaritaLoseva/testcafe.git","ssh_url":"git@github.com:MargaritaLoseva/testcafe.git","clone_url":"https://github.com/MargaritaLoseva/testcafe.git","svn_url":"https://github.com/MargaritaLoseva/testcafe","homepage":null,"size":40066,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"DevExpress:master","ref":"master","sha":"766b8b8e3169b381dc08e7cf720740eb34500c39","user":{"login":"DevExpress","id":4243232,"avatar_url":"https://avatars0.githubusercontent.com/u/4243232?v=4","gravatar_id":"","url":"https://api.github.com/users/DevExpress","html_url":"https://github.com/DevExpress","followers_url":"https://api.github.com/users/DevExpress/followers","following_url":"https://api.github.com/users/DevExpress/following{/other_user}","gists_url":"https://api.github.com/users/DevExpress/gists{/gist_id}","starred_url":"https://api.github.com/users/DevExpress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevExpress/subscriptions","organizations_url":"https://api.github.com/users/DevExpress/orgs","repos_url":"https://api.github.com/users/DevExpress/repos","events_url":"https://api.github.com/users/DevExpress/events{/privacy}","received_events_url":"https://api.github.com/users/DevExpress/received_events","type":"Organization","site_admin":false},"repo":{"id":34262857,"name":"testcafe","full_name":"DevExpress/testcafe","owner":{"login":"DevExpress","id":4243232,"avatar_url":"https://avatars0.githubusercontent.com/u/4243232?v=4","gravatar_id":"","url":"https://api.github.com/users/DevExpress","html_url":"https://github.com/DevExpress","followers_url":"https://api.github.com/users/DevExpress/followers","following_url":"https://api.github.com/users/DevExpress/following{/other_user}","gists_url":"https://api.github.com/users/DevExpress/gists{/gist_id}","starred_url":"https://api.github.com/users/DevExpress/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DevExpress/subscriptions","organizations_url":"https://api.github.com/users/DevExpress/orgs","repos_url":"https://api.github.com/users/DevExpress/repos","events_url":"https://api.github.com/users/DevExpress/events{/privacy}","received_events_url":"https://api.github.com/users/DevExpress/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DevExpress/testcafe","description":"A Node.js tool to automate end-to-end web testing.","fork":false,"url":"https://api.github.com/repos/DevExpress/testcafe","forks_url":"https://api.github.com/repos/DevExpress/testcafe/forks","keys_url":"https://api.github.com/repos/DevExpress/testcafe/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DevExpress/testcafe/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DevExpress/testcafe/teams","hooks_url":"https://api.github.com/repos/DevExpress/testcafe/hooks","issue_events_url":"https://api.github.com/repos/DevExpress/testcafe/issues/events{/number}","events_url":"https://api.github.com/repos/DevExpress/testcafe/events","assignees_url":"https://api.github.com/repos/DevExpress/testcafe/assignees{/user}","branches_url":"https://api.github.com/repos/DevExpress/testcafe/branches{/branch}","tags_url":"https://api.github.com/repos/DevExpress/testcafe/tags","blobs_url":"https://api.github.com/repos/DevExpress/testcafe/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DevExpress/testcafe/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DevExpress/testcafe/git/refs{/sha}","trees_url":"https://api.github.com/repos/DevExpress/testcafe/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DevExpress/testcafe/statuses/{sha}","languages_url":"https://api.github.com/repos/DevExpress/testcafe/languages","stargazers_url":"https://api.github.com/repos/DevExpress/testcafe/stargazers","contributors_url":"https://api.github.com/repos/DevExpress/testcafe/contributors","subscribers_url":"https://api.github.com/repos/DevExpress/testcafe/subscribers","subscription_url":"https://api.github.com/repos/DevExpress/testcafe/subscription","commits_url":"https://api.github.com/repos/DevExpress/testcafe/commits{/sha}","git_commits_url":"https://api.github.com/repos/DevExpress/testcafe/git/commits{/sha}","comments_url":"https://api.github.com/repos/DevExpress/testcafe/comments{/number}","issue_comment_url":"https://api.github.com/repos/DevExpress/testcafe/issues/comments{/number}","contents_url":"https://api.github.com/repos/DevExpress/testcafe/contents/{+path}","compare_url":"https://api.github.com/repos/DevExpress/testcafe/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DevExpress/testcafe/merges","archive_url":"https://api.github.com/repos/DevExpress/testcafe/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DevExpress/testcafe/downloads","issues_url":"https://api.github.com/repos/DevExpress/testcafe/issues{/number}","pulls_url":"https://api.github.com/repos/DevExpress/testcafe/pulls{/number}","milestones_url":"https://api.github.com/repos/DevExpress/testcafe/milestones{/number}","notifications_url":"https://api.github.com/repos/DevExpress/testcafe/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DevExpress/testcafe/labels{/name}","releases_url":"https://api.github.com/repos/DevExpress/testcafe/releases{/id}","deployments_url":"https://api.github.com/repos/DevExpress/testcafe/deployments","created_at":"2015-04-20T13:43:28Z","updated_at":"2018-03-05T14:15:19Z","pushed_at":"2018-03-05T14:39:11Z","git_url":"git://github.com/DevExpress/testcafe.git","ssh_url":"git@github.com:DevExpress/testcafe.git","clone_url":"https://github.com/DevExpress/testcafe.git","svn_url":"https://github.com/DevExpress/testcafe","homepage":"https://devexpress.github.io/testcafe/","size":41809,"stargazers_count":4231,"watchers_count":4231,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":218,"mirror_url":null,"archived":false,"open_issues_count":230,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":218,"open_issues":230,"watchers":4231,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193"},"html":{"href":"https://github.com/DevExpress/testcafe/pull/2193"},"issue":{"href":"https://api.github.com/repos/DevExpress/testcafe/issues/2193"},"comments":{"href":"https://api.github.com/repos/DevExpress/testcafe/issues/2193/comments"},"review_comments":{"href":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193/comments"},"review_comment":{"href":"https://api.github.com/repos/DevExpress/testcafe/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/DevExpress/testcafe/pulls/2193/commits"},"statuses":{"href":"https://api.github.com/repos/DevExpress/testcafe/statuses/72b5a123d8fbbd112e9fb6249dc72851b9a40e42"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"helen-dikareva"}}