From a93f786ba5b03aa26e4810b1c07edbff39e426e1 Mon Sep 17 00:00:00 2001 From: shadowusr <58862284+shadowusr@users.noreply.github.com> Date: Thu, 18 Jul 2024 11:10:55 +0300 Subject: [PATCH] docs: add en versions of element commands (#18) --- .../current/commands/element/$$.mdx | 98 ++++++++++ .../current/commands/element/$.mdx | 123 ++++++++++++ .../current/commands/element/addValue.mdx | 46 +++++ .../current/commands/element/assertView.mdx | 177 ++++++++++++++++++ .../current/commands/element/clearValue.mdx | 46 +++++ .../current/commands/element/click.mdx | 139 ++++++++++++++ .../current/commands/element/doubleClick.mdx | 36 ++++ .../current/commands/element/dragAndDrop.mdx | 43 +++++ .../current/commands/element/getAttribute.mdx | 49 +++++ .../commands/element/getCSSProperty.mdx | 106 +++++++++++ .../commands/element/getComputedLabel.mdx | 27 +++ .../commands/element/getComputedRole.mdx | 27 +++ .../current/commands/element/getHTML.mdx | 53 ++++++ .../current/commands/element/getLocation.mdx | 46 +++++ .../current/commands/element/getProperty.mdx | 37 ++++ .../current/commands/element/getSize.mdx | 45 +++++ .../current/commands/element/getTagName.mdx | 33 ++++ .../current/commands/element/getText.mdx | 52 +++++ .../current/commands/element/getValue.mdx | 37 ++++ .../current/commands/element/isClickable.mdx | 49 +++++ .../current/commands/element/isDisplayed.mdx | 61 ++++++ .../element/isDisplayedInViewport.mdx | 49 +++++ .../current/commands/element/isEnabled.mdx | 45 +++++ .../current/commands/element/isEqual.mdx | 43 +++++ .../current/commands/element/isExisting.mdx | 61 ++++++ .../current/commands/element/isFocused.mdx | 40 ++++ .../current/commands/element/isSelected.mdx | 41 ++++ .../current/commands/element/moveTo.mdx | 32 ++++ .../current/commands/element/nextElement.mdx | 43 +++++ .../commands/element/parentElement.mdx | 43 +++++ .../commands/element/previousElement.mdx | 43 +++++ .../current/commands/element/reactDollar.mdx | 81 ++++++++ .../commands/element/reactDollarDollar.mdx | 62 ++++++ .../commands/element/saveScreenshot.mdx | 36 ++++ .../commands/element/scrollIntoView.mdx | 66 +++++++ .../commands/element/selectByAttribute.mdx | 64 +++++++ .../commands/element/selectByIndex.mdx | 59 ++++++ .../commands/element/selectByVisibleText.mdx | 59 ++++++ .../current/commands/element/setValue.mdx | 57 ++++++ .../current/commands/element/shadowDollar.mdx | 42 +++++ .../commands/element/shadowDollarDollar.mdx | 42 +++++ .../current/commands/element/touchAction.mdx | 86 +++++++++ .../commands/element/waitForClickable.mdx | 53 ++++++ .../commands/element/waitForDisplayed.mdx | 66 +++++++ .../commands/element/waitForEnabled.mdx | 66 +++++++ .../current/commands/element/waitForExist.mdx | 63 +++++++ .../current/commands/element/waitUntil.mdx | 65 +++++++ 47 files changed, 2737 insertions(+) create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/$$.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/$.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/addValue.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/assertView.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/clearValue.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/click.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/doubleClick.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/dragAndDrop.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getAttribute.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getCSSProperty.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getComputedLabel.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getComputedRole.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getHTML.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getLocation.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getProperty.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getSize.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getTagName.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getText.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/getValue.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isClickable.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isDisplayed.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isDisplayedInViewport.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isEnabled.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isEqual.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isExisting.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isFocused.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/isSelected.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/moveTo.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/nextElement.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/parentElement.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/previousElement.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/reactDollar.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/reactDollarDollar.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/saveScreenshot.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/scrollIntoView.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/selectByAttribute.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/selectByIndex.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/selectByVisibleText.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/setValue.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/shadowDollar.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/shadowDollarDollar.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/touchAction.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/waitForClickable.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/waitForDisplayed.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/waitForEnabled.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/waitForExist.mdx create mode 100644 i18n/en/docusaurus-plugin-content-docs/current/commands/element/waitUntil.mdx diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/element/$$.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/element/$$.mdx new file mode 100644 index 0000000..6f1216c --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/element/$$.mdx @@ -0,0 +1,98 @@ +--- +slug: _dollardollar +sidebar_label: $$ +--- + +import Admonition from "@theme/Admonition"; + +# $$ + +## Overview {#overview} + +Use the `$$` command instead of [findElements][find-elements] as a shorter command to get multiple elements on the page within the scope of an element. This command is similar to the [browser.$$()](../../browser/_dollardollar) command but differs in that the search for elements will be among the children of the current element. + + + Read more about how to select specific elements in the recipe "[How to use + selectors][how-to-use-selectors]". + + +## Usage {#usage} + +```javascript +await browser.$(selector).$$(subSelector); +``` + +## Command Parameters {#parameters} + + + + + + + + + +
**Name****Type****Description**
subSelectorString or Function or MatcherSelector, JS function, or Matcher object to get multiple elements.
+ +## Usage Examples {#examples} + +**index.html** + +```html + +``` + +**$$.js** + +```javascript +it("should get text of a menu link", async ({ browser }) => { + const text = await browser.$("#menu"); + + console.log(await text.$$("li")[2].$("a").getText()); // outputs: "API" +}); + +it("should get text of a menu link - JS Function", async ({ browser }) => { + const text = await browser.$("#menu"); + + console.log( + await text + .$$(function () { + // Arrow function cannot be used here. + // This is Element – https://developer.mozilla.org/en-US/docs/Web/API/Element + // in this specific example – this is HTMLUListElement + // + // TypeScript users can do something like: + // return (this as Element).querySelector('li') + return this.querySelectorAll("li"); // Element[] + })[2] + .$("a") + .getText(), + ); // outputs: "API" +}); +``` + +## Related Commands + +- [element.$](../_dollar) +- [browser.$](../../browser/_dollar) +- [browser.$$](../../browser/_dollardollar) + +## References + +We'd like to give credit to the original WebdriverIO docs [article](https://webdriver.io/docs/api/element/$$), from which we drew some information while writing our version. + +[find-elements]: https://webdriver.io/docs/api/webdriver/#findelements +[how-to-use-selectors]: https://webdriver.io/docs/selectors diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/element/$.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/element/$.mdx new file mode 100644 index 0000000..ec7edc6 --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/element/$.mdx @@ -0,0 +1,123 @@ +--- +slug: _dollar +sidebar_position: 1 +--- + +import Admonition from "@theme/Admonition"; + +# $ + +## Overview {#overview} + +Use the `$` command instead of [findElement][find-element] as a shorter command to get a single element on the page. + +The `$` command returns an object describing the element, on which you can call action commands without passing the selector. However, if you do pass a selector, it will first find the corresponding element and then call the action for that element. You can also pass an object as the selector, where the object contains the property `element-6066-11e4-a52e-4f735466cecf` with the value of the element reference. The command then converts the reference into an extended WebdriverIO element. Note: Use these element objects only if you are certain they exist on the page. This can be verified, for example, using the [isExisting](../isExisting) command. + +You can chain `$` or `$$` together to navigate down the DOM tree. But note that chaining `$` and `$$` commands makes sense only when using multiple selector strategies. Otherwise, you will be making unnecessary requests that will slow down the test (e.g., `$('body').$('div')` creates two requests, whereas `$('body div')` does the same in one request). + + + Read more about how to select specific elements in the recipe "[How to use + selectors][how-to-use-selectors]". + + +## Usage {#usage} + +```javascript +await browser.$(selector); +``` + +## Command Parameters {#parameters} + + + + + + + + + +
**Name****Type****Description**
selectorString or Function or MatcherSelector, JS function, or Matcher object to get a specific element.
+ +## Usage Examples {#examples} + +**index.html** + +```html + +``` + +```javascript +it("should get text of a menu link - JS Function", async ({ browser }) => { + const text = await browser.$("#menu"); + + console.log( + await text + .$$("li")[2] + .$(function () { + // Arrow function cannot be used here. + // This is Element – https://developer.mozilla.org/en-US/docs/Web/API/Element + // in this specific example – this is HTMLLIElement + // + // TypeScript users can do something like: + // return (this as Element).querySelector('a') + return this.querySelector("a"); // Element + }) + .getText(), + ); // outputs: "API" +}); + +it("should get text of a menu link", async ({ browser }) => { + const text = await browser.$("#menu"); + + console.log(await text.$$("li")[2].$("a").getText()); // outputs: "API" +}); + +it("should allow to convert protocol result of an element into a WebdriverIO element", async ({ + browser, +}) => { + const activeElement = await browser.getActiveElement(); + + console.log(await browser.$(activeElement).getTagName()); // outputs the active element +}); + +it("should use Android's DataMatcher or ViewMatcher selector", async ({ browser }) => { + const menuItem = await browser.$({ + name: "hasEntry", + args: ["title", "ViewTitle"], + class: "androidx.test.espresso.matcher.ViewMatchers", + }); + await menuItem.click(); + + const menuItem = await browser.$({ + name: "hasEntry", + args: ["title", "ViewTitle"], + }); + await menuItem.click(); +}); +``` + +## Related Commands {#related} + +- [element.$$](../_dollardollar) +- [browser.$](../../browser/_dollar) +- [browser.$$](../../browser/_dollardollar) + +## References + +We'd like to give credit to the original WebdriverIO docs [article](https://webdriver.io/docs/api/element/$), from which we drew some information while writing our version. + +[find-element]: https://webdriver.io/docs/api/webdriver/#findelement +[how-to-use-selectors]: https://webdriver.io/docs/selectors diff --git a/i18n/en/docusaurus-plugin-content-docs/current/commands/element/addValue.mdx b/i18n/en/docusaurus-plugin-content-docs/current/commands/element/addValue.mdx new file mode 100644 index 0000000..d2989ba --- /dev/null +++ b/i18n/en/docusaurus-plugin-content-docs/current/commands/element/addValue.mdx @@ -0,0 +1,46 @@ +# addValue + +## Overview {#overview} + +Use the `addValue` command to add a value to an `` or `