Skip to content

Commit

Permalink
Added section on ByAll (#1939)[deploy site]
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
shbenzer authored Sep 17, 2024
1 parent ac20ce5 commit 6c6d153
Show file tree
Hide file tree
Showing 5 changed files with 146 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,32 @@
package dev.selenium.elements;
import org.openqa.selenium.By;
import org.openqa.selenium.support.pagefactory.ByAll;
import org.openqa.selenium.support.pagefactory.ByChained;
import dev.selenium.BaseTest;
import java.util.List;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class LocatorsTest extends BaseTest {


public void ByAllTest() {
// Create instance of ChromeDriver
WebDriver driver = new ChromeDriver();
// Navigate to Url
driver.get("https://www.selenium.dev/selenium/web/login.html");

// get both logins
By example = new ByAll(By.id("password-field"), By.id("username-field"));
List<WebElement> login_inputs = driver.findElements(example);

//send them both input
login_inputs.get(0).sendKeys("username");
login_inputs.get(1).sendKeys("password");
}

public String ByChainedTest() {
// Create instance of ChromeDriver
WebDriver driver = new ChromeDriver();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,12 +370,39 @@ others it's as simple as setting a parameter in the FindElement function

### ByChained

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.
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.

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Kotlin" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< /tabpane >}}

### ByAll

The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields
seperately, you can instead find them together in one clean `FindElements()`

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,40 @@ others it's as simple as setting a parameter in the FindElement function

### ByChained

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.
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.

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Kotlin" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< /tabpane >}}

### ByAll

The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields seperately,
you can instead find them together in one clean `FindElements()`

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,40 @@ others it's as simple as setting a parameter in the FindElement function

### ByChained

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.
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.

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Kotlin" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< /tabpane >}}

### ByAll

The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields
seperately, you can instead find them together in one clean `FindElements()`

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,40 @@ others it's as simple as setting a parameter in the FindElement function

### ByChained

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.
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.

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#17-19" >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L37-L38" >}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="CSharp" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Ruby" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="JavaScript" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< tab header="Kotlin" text=true >}}
{{< badge-code >}}
{{< /tab >}}
{{< /tabpane >}}

### ByAll

The `ByAll` class enables you to utilize two By locators at once, finding elements that mach _either_ of your By locators.
For example, instead of having to utilize two `FindElement()` functions to find the username and password input fields
seperately, you can instead find them together in one clean `FindElements()`

{{< tabpane langEqualsHeader=true >}}
{{< tab header="Java" text=true >}}
{{< gh-codeblock path="/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#L22-L23">}}
{{< /tab >}}
{{< tab header="Python" text=true >}}
{{< badge-code >}}
Expand Down

0 comments on commit 6c6d153

Please sign in to comment.