Skip to content

Commit 6c6d153

Browse files
authored
Added section on ByAll (#1939)[deploy site]
* added section on ByAll * Update locators.en.md * Update locators.ja.md * Update locators.en.md * Update locators.pt-br.md * Update locators.zh-cn.md * removed erroneous dependency * Update pom.xml
1 parent ac20ce5 commit 6c6d153

File tree

5 files changed

+146
-16
lines changed

5 files changed

+146
-16
lines changed

examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java

+19
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
package dev.selenium.elements;
22
import org.openqa.selenium.By;
3+
import org.openqa.selenium.support.pagefactory.ByAll;
34
import org.openqa.selenium.support.pagefactory.ByChained;
45
import dev.selenium.BaseTest;
6+
import java.util.List;
7+
58
import org.openqa.selenium.WebDriver;
69
import org.openqa.selenium.WebElement;
710
import org.openqa.selenium.chrome.ChromeDriver;
811

912
public class LocatorsTest extends BaseTest {
1013

14+
15+
public void ByAllTest() {
16+
// Create instance of ChromeDriver
17+
WebDriver driver = new ChromeDriver();
18+
// Navigate to Url
19+
driver.get("https://www.selenium.dev/selenium/web/login.html");
20+
21+
// get both logins
22+
By example = new ByAll(By.id("password-field"), By.id("username-field"));
23+
List<WebElement> login_inputs = driver.findElements(example);
24+
25+
//send them both input
26+
login_inputs.get(0).sendKeys("username");
27+
login_inputs.get(1).sendKeys("password");
28+
}
29+
1130
public String ByChainedTest() {
1231
// Create instance of ChromeDriver
1332
WebDriver driver = new ChromeDriver();

website_and_docs/content/documentation/webdriver/elements/locators.en.md

+31-4
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,39 @@ others it's as simple as setting a parameter in the FindElement function
370370

371371
### ByChained
372372

373-
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of having to locate a parent element, and then a child element of that parent, you can instead combine those two `FindElement` functions into one.
373+
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of having to locate a parent element,
374+
and then a child element of that parent, you can instead combine those two `FindElement()` functions into one.
374375

375376
{{< tabpane langEqualsHeader=true >}}
376-
{{< badge-examples >}}
377-
{{< tab header="Java" >}}
378-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
377+
{{< tab header="Java" text=true >}}
378+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38">}}
379+
{{< /tab >}}
380+
{{< tab header="Python" text=true >}}
381+
{{< badge-code >}}
382+
{{< /tab >}}
383+
{{< tab header="CSharp" text=true >}}
384+
{{< badge-code >}}
385+
{{< /tab >}}
386+
{{< tab header="Ruby" text=true >}}
387+
{{< badge-code >}}
388+
{{< /tab >}}
389+
{{< tab header="JavaScript" text=true >}}
390+
{{< badge-code >}}
391+
{{< /tab >}}
392+
{{< tab header="Kotlin" text=true >}}
393+
{{< badge-code >}}
394+
{{< /tab >}}
395+
{{< /tabpane >}}
396+
397+
### ByAll
398+
399+
The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
400+
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields
401+
seperately, you can instead find them together in one clean `FindElements()`
402+
403+
{{< tabpane langEqualsHeader=true >}}
404+
{{< tab header="Java" text=true >}}
405+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
379406
{{< /tab >}}
380407
{{< tab header="Python" text=true >}}
381408
{{< badge-code >}}

website_and_docs/content/documentation/webdriver/elements/locators.ja.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -360,12 +360,40 @@ others it's as simple as setting a parameter in the FindElement function
360360

361361
### ByChained
362362

363-
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of having to locate a parent element, and then a child element of that parent, you can instead combine those two `FindElement` functions into one.
363+
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of having to
364+
locate a parent element, and then a child element of that parent, you can instead combine those two `FindElement`
365+
functions into one.
364366

365367
{{< tabpane langEqualsHeader=true >}}
366-
{{< badge-examples >}}
367-
{{< tab header="Java" >}}
368-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
368+
{{< tab header="Java" text=true >}}
369+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38" >}}
370+
{{< /tab >}}
371+
{{< tab header="Python" text=true >}}
372+
{{< badge-code >}}
373+
{{< /tab >}}
374+
{{< tab header="CSharp" text=true >}}
375+
{{< badge-code >}}
376+
{{< /tab >}}
377+
{{< tab header="Ruby" text=true >}}
378+
{{< badge-code >}}
379+
{{< /tab >}}
380+
{{< tab header="JavaScript" text=true >}}
381+
{{< badge-code >}}
382+
{{< /tab >}}
383+
{{< tab header="Kotlin" text=true >}}
384+
{{< badge-code >}}
385+
{{< /tab >}}
386+
{{< /tabpane >}}
387+
388+
### ByAll
389+
390+
The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
391+
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields seperately,
392+
you can instead find them together in one clean `FindElements()`
393+
394+
{{< tabpane langEqualsHeader=true >}}
395+
{{< tab header="Java" text=true >}}
396+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
369397
{{< /tab >}}
370398
{{< tab header="Python" text=true >}}
371399
{{< badge-code >}}

website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,40 @@ others it's as simple as setting a parameter in the FindElement function
363363

364364
### ByChained
365365

366-
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of having to locate a parent element, and then a child element of that parent, you can instead combine those two `FindElement` functions into one.
366+
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of
367+
having to locate a parent element, and then a child element of that parent, you can instead
368+
combine those two `FindElement` functions into one.
367369

368370
{{< tabpane langEqualsHeader=true >}}
369-
{{< badge-examples >}}
370-
{{< tab header="Java" >}}
371-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
371+
{{< tab header="Java" text=true >}}
372+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38" >}}
373+
{{< /tab >}}
374+
{{< tab header="Python" text=true >}}
375+
{{< badge-code >}}
376+
{{< /tab >}}
377+
{{< tab header="CSharp" text=true >}}
378+
{{< badge-code >}}
379+
{{< /tab >}}
380+
{{< tab header="Ruby" text=true >}}
381+
{{< badge-code >}}
382+
{{< /tab >}}
383+
{{< tab header="JavaScript" text=true >}}
384+
{{< badge-code >}}
385+
{{< /tab >}}
386+
{{< tab header="Kotlin" text=true >}}
387+
{{< badge-code >}}
388+
{{< /tab >}}
389+
{{< /tabpane >}}
390+
391+
### ByAll
392+
393+
The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
394+
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields
395+
seperately, you can instead find them together in one clean `FindElements()`
396+
397+
{{< tabpane langEqualsHeader=true >}}
398+
{{< tab header="Java" text=true >}}
399+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
372400
{{< /tab >}}
373401
{{< tab header="Python" text=true >}}
374402
{{< badge-code >}}

website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md

+32-4
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,40 @@ others it's as simple as setting a parameter in the FindElement function
363363

364364
### ByChained
365365

366-
The `ByChained` class enables you to _chain_ two By locators together. For example, instead of having to locate a parent element, and then a child element of that parent, you can instead combine those two `FindElement` functions into one.
366+
The `ByChained` class enables you to _chain_ two By locators together. For example,
367+
instead of having to locate a parent element, and then a child element of that parent,
368+
you can instead combine those two `FindElement` functions into one.
367369

368370
{{< tabpane langEqualsHeader=true >}}
369-
{{< badge-examples >}}
370-
{{< tab header="Java" >}}
371-
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
371+
{{< tab header="Java" text=true >}}
372+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38" >}}
373+
{{< /tab >}}
374+
{{< tab header="Python" text=true >}}
375+
{{< badge-code >}}
376+
{{< /tab >}}
377+
{{< tab header="CSharp" text=true >}}
378+
{{< badge-code >}}
379+
{{< /tab >}}
380+
{{< tab header="Ruby" text=true >}}
381+
{{< badge-code >}}
382+
{{< /tab >}}
383+
{{< tab header="JavaScript" text=true >}}
384+
{{< badge-code >}}
385+
{{< /tab >}}
386+
{{< tab header="Kotlin" text=true >}}
387+
{{< badge-code >}}
388+
{{< /tab >}}
389+
{{< /tabpane >}}
390+
391+
### ByAll
392+
393+
The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
394+
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields
395+
seperately, you can instead find them together in one clean `FindElements()`
396+
397+
{{< tabpane langEqualsHeader=true >}}
398+
{{< tab header="Java" text=true >}}
399+
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
372400
{{< /tab >}}
373401
{{< tab header="Python" text=true >}}
374402
{{< badge-code >}}

0 commit comments

Comments
 (0)