Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.compile.nullAnalysis.mode": "automatic"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
package dev.selenium.elements;

import org.openqa.selenium.By;
import org.openqa.selenium.support.pagefactory.ByChained;
import dev.selenium.BaseTest;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class LocatorsTest extends BaseTest {

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

// Find username-field inside of login-form
By example = new ByChained(By.id("login-form"), By.id("username-field"));
WebElement username_input = driver.findElement(example);

//return placeholder text
String placeholder = username_input.getAttribute("placeholder");
return placeholder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ The FindElement makes using locators a breeze! For most languages,
all you need to do is utilize `webdriver.common.by.By`, however in
others it's as simple as setting a parameter in the FindElement function

### By

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
Expand Down Expand Up @@ -366,6 +368,32 @@ others it's as simple as setting a parameter in the FindElement function
{{< /tab >}}
{{< /tabpane >}}

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

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#11-25" >}}
{{< /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 >}}

## Relative Locators

**Selenium 4** introduces Relative Locators (previously
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ The FindElement makes using locators a breeze! For most languages,
all you need to do is utilize `webdriver.common.by.By`, however in
others it's as simple as setting a parameter in the FindElement function

### By

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
Expand Down Expand Up @@ -356,7 +358,31 @@ others it's as simple as setting a parameter in the FindElement function
{{< /tab >}}
{{< /tabpane >}}

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

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#11-25" >}}
{{< /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 >}}

## 相対ロケーター

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ The FindElement makes using locators a breeze! For most languages,
all you need to do is utilize `webdriver.common.by.By`, however in
others it's as simple as setting a parameter in the FindElement function

### By

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
Expand Down Expand Up @@ -359,6 +361,32 @@ others it's as simple as setting a parameter in the FindElement function
{{< /tab >}}
{{< /tabpane >}}

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

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#11-25" >}}
{{< /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 >}}

## Relative Locators

**Selenium 4** introduces Relative Locators (previously
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,8 @@ The FindElement makes using locators a breeze! For most languages,
all you need to do is utilize `webdriver.common.by.By`, however in
others it's as simple as setting a parameter in the FindElement function

### By

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
Expand Down Expand Up @@ -359,6 +361,32 @@ others it's as simple as setting a parameter in the FindElement function
{{< /tab >}}
{{< /tabpane >}}

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

{{< tabpane langEqualsHeader=true >}}
{{< badge-examples >}}
{{< tab header="Java" >}}
{{< gh-codeblock path="examples/java/src/test/java/dev/selenium/elements/LocatorsTest.java#11-25" >}}
{{< /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 >}}

## Relative Locators

**Selenium 4** introduces Relative Locators (previously
Expand Down