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 `