From 2cb03be3272ac58064cc516a1b2dd2c1efa27068 Mon Sep 17 00:00:00 2001 From: Simon Benzer Date: Wed, 11 Sep 2024 10:37:03 -0400 Subject: [PATCH 1/8] added section on ByAll --- examples/java/pom.xml | 6 ++++ .../dev/selenium/elements/LocatorsTest.java | 19 +++++++++++ .../webdriver/elements/locators.en.md | 32 ++++++++++++++++--- .../webdriver/elements/locators.ja.md | 30 +++++++++++++++-- .../webdriver/elements/locators.pt-br.md | 30 +++++++++++++++-- .../webdriver/elements/locators.zh-cn.md | 30 +++++++++++++++-- 6 files changed, 134 insertions(+), 13 deletions(-) diff --git a/examples/java/pom.xml b/examples/java/pom.xml index 411a96133f81..dac992a815cd 100644 --- a/examples/java/pom.xml +++ b/examples/java/pom.xml @@ -48,6 +48,12 @@ selenium-logger 2.4.0 + + + org.scala-lang + scala-library + 2.13.0 + diff --git a/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java b/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java index 6e98ce25c6e2..bcc473f7a8be 100644 --- a/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java +++ b/examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java @@ -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 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(); diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.en.md b/website_and_docs/content/documentation/webdriver/elements/locators.en.md index 3a7751845753..67756cad1f3f 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -370,12 +370,36 @@ 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 >}} diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md index 0547c0be8aad..cf9f6d160ca3 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md @@ -363,9 +363,33 @@ others it's as simple as setting a parameter in the FindElement function 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 >}} diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md index f8c851b386ab..80341886c90b 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md @@ -366,9 +366,33 @@ others it's as simple as setting a parameter in the FindElement function 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 >}} diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md index e1cc00eacf53..745ad0f89d74 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md @@ -366,9 +366,33 @@ others it's as simple as setting a parameter in the FindElement function 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 >}} From 337290203790f7d2950fb4fae3b8cdf56fa9dfa0 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:12:33 -0400 Subject: [PATCH 2/8] Update locators.en.md --- .../content/documentation/webdriver/elements/locators.en.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.en.md b/website_and_docs/content/documentation/webdriver/elements/locators.en.md index 67756cad1f3f..5fc5d4fa9bf1 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -395,7 +395,9 @@ The `ByChained` class enables you to _chain_ two By locators together. For examp ### 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()` +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 >}} From 2aa396b62bb578f90d004b36f41073f9b5e877d5 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:13:22 -0400 Subject: [PATCH 3/8] Update locators.ja.md --- .../documentation/webdriver/elements/locators.ja.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md index cf9f6d160ca3..28b11bcd66cc 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md @@ -360,7 +360,9 @@ 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 >}} {{< tab header="Java" text=true >}} @@ -385,7 +387,9 @@ The `ByChained` class enables you to _chain_ two By locators together. For examp ### 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()` +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 >}} From 3179c1a7d9cdeaaae1ec2fac9a521e4641ef1b9a Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:13:48 -0400 Subject: [PATCH 4/8] Update locators.en.md --- .../content/documentation/webdriver/elements/locators.en.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.en.md b/website_and_docs/content/documentation/webdriver/elements/locators.en.md index 5fc5d4fa9bf1..d08963fd063d 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -370,7 +370,8 @@ 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 >}} {{< tab header="Java" text=true >}} From e808cbcd9fcc0a4e8bf2aecbcec0bbb1042b3252 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:14:25 -0400 Subject: [PATCH 5/8] Update locators.pt-br.md --- .../documentation/webdriver/elements/locators.pt-br.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md index 80341886c90b..de57a4812d37 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md @@ -363,7 +363,9 @@ 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 >}} {{< tab header="Java" text=true >}} @@ -388,7 +390,9 @@ The `ByChained` class enables you to _chain_ two By locators together. For examp ### 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()` +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 >}} From be4f345d4e6a85e8450c42825f120f2c6350163a Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:15:17 -0400 Subject: [PATCH 6/8] Update locators.zh-cn.md --- .../documentation/webdriver/elements/locators.zh-cn.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md index 745ad0f89d74..b8e38f81faff 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.zh-cn.md @@ -363,7 +363,9 @@ 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 >}} {{< tab header="Java" text=true >}} @@ -388,7 +390,9 @@ The `ByChained` class enables you to _chain_ two By locators together. For examp ### 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()` +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 >}} From 128018789a63eb43a28ba4d510860a11caf2f137 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:19:52 -0400 Subject: [PATCH 7/8] removed erroneous dependency --- examples/java/pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/examples/java/pom.xml b/examples/java/pom.xml index dac992a815cd..fc85c06d729a 100644 --- a/examples/java/pom.xml +++ b/examples/java/pom.xml @@ -49,11 +49,6 @@ 2.4.0 - - org.scala-lang - scala-library - 2.13.0 - From e8cd71d6f1fabb7807b6f630f9e67135af2e7011 Mon Sep 17 00:00:00 2001 From: Simon Benzer <69980130+shbenzer@users.noreply.github.com> Date: Tue, 17 Sep 2024 09:20:32 -0400 Subject: [PATCH 8/8] Update pom.xml --- examples/java/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/java/pom.xml b/examples/java/pom.xml index fc85c06d729a..411a96133f81 100644 --- a/examples/java/pom.xml +++ b/examples/java/pom.xml @@ -48,7 +48,6 @@ selenium-logger 2.4.0 -