Skip to content

Added section on ByAll #1939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading