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 3765f88dbc02..abaa09581f37 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.en.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.en.md @@ -314,7 +314,7 @@ first name text box. Let us create locator for female radio button using xpath. {{< /tab >}} {{< tab header="CSharp" >}} var driver = new ChromeDriver(); - driver.FindElement(By.Xpath("//input[@value='f']")); + driver.FindElement(By.Xpath("//input[@value='f']")); {{< /tab >}} {{< tab header="Ruby" text=true >}} {{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L35" >}} @@ -324,11 +324,45 @@ first name text box. Let us create locator for female radio button using xpath. const loc = await driver.findElement(By.xpath('//input[@value='f']')); {{< /tab >}} {{< tab header="Kotlin" >}} + import org.openqa.selenium.By val driver = ChromeDriver() - val loc: WebElement = driver.findElement(By.xpath('//input[@value='f']')) + val loc: WebElement = driver.findElement(By.xpath('//input[@value='f']')) {{< /tab >}} {{< /tabpane >}} +## Utilizing Locators + +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> + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} + {{< tab header="Java" >}} + import org.openqa.selenium.By; + WebDriver driver = new ChromeDriver(); + driver.findElement(By.className("information")); + {{< /tab >}} + {{< tab header="Python" >}} + from selenium.webdriver.common.by import By + driver = webdriver.Chrome() + driver.find_element(By.CLASS_NAME, "information") + {{< /tab >}} + {{< tab header="CSharp" >}} + var driver = new ChromeDriver(); + driver.FindElement(By.ClassName("information")); + {{< /tab >}} + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L7" >}} + {{< /tab >}} + {{< tab header="JavaScript" >}} + let driver = await new Builder().forBrowser('chrome').build(); + const loc = await driver.findElement(By.className('information')); + {{< /tab >}} + {{< tab header="Kotlin" >}} + import org.openqa.selenium.By + val driver = ChromeDriver() + val loc: WebElement = driver.findElement(By.className("information")) + {{< /tab >}} +{{< /tabpane >}} ## Relative Locators 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 41541e1c4beb..bcb56690428b 100644 --- a/website_and_docs/content/documentation/webdriver/elements/locators.ja.md +++ b/website_and_docs/content/documentation/webdriver/elements/locators.ja.md @@ -320,6 +320,40 @@ first name text box. Let us create locator for female radio button using xpath. {{< /tab >}} {{< /tabpane >}} +## Utilizing Locators + +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> + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} + {{< tab header="Java" >}} + import org.openqa.selenium.By; + WebDriver driver = new ChromeDriver(); + driver.findElement(By.className("information")); + {{< /tab >}} + {{< tab header="Python" >}} + from selenium.webdriver.common.by import By + driver = webdriver.Chrome() + driver.find_element(By.CLASS_NAME, "information") + {{< /tab >}} + {{< tab header="CSharp" >}} + var driver = new ChromeDriver(); + driver.FindElement(By.ClassName("information")); + {{< /tab >}} + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L7" >}} + {{< /tab >}} + {{< tab header="JavaScript" >}} + let driver = await new Builder().forBrowser('chrome').build(); + const loc = await driver.findElement(By.className('information')); + {{< /tab >}} + {{< tab header="Kotlin" >}} + import org.openqa.selenium.By + val driver = ChromeDriver() + val loc: WebElement = driver.findElement(By.className("information")) + {{< /tab >}} +{{< /tabpane >}} + ## 相対ロケーター 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 21f710a4fd5f..6ee45b176f25 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 @@ -323,7 +323,39 @@ first name text box. Let us create locator for female radio button using xpath. {{< /tab >}} {{< /tabpane >}} +## Utilizing Locators +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> + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} + {{< tab header="Java" >}} + import org.openqa.selenium.By; + WebDriver driver = new ChromeDriver(); + driver.findElement(By.className("information")); + {{< /tab >}} + {{< tab header="Python" >}} + from selenium.webdriver.common.by import By + driver = webdriver.Chrome() + driver.find_element(By.CLASS_NAME, "information") + {{< /tab >}} + {{< tab header="CSharp" >}} + var driver = new ChromeDriver(); + driver.FindElement(By.ClassName("information")); + {{< /tab >}} + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L7" >}} + {{< /tab >}} + {{< tab header="JavaScript" >}} + let driver = await new Builder().forBrowser('chrome').build(); + const loc = await driver.findElement(By.className('information')); + {{< /tab >}} + {{< tab header="Kotlin" >}} + import org.openqa.selenium.By + val driver = ChromeDriver() + val loc: WebElement = driver.findElement(By.className("information")) + {{< /tab >}} +{{< /tabpane >}} ## Relative Locators 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 1a8d80ece046..a037f3536338 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 @@ -323,7 +323,39 @@ first name text box. Let us create locator for female radio button using xpath. {{< /tab >}} {{< /tabpane >}} +## Utilizing Locators +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> + +{{< tabpane langEqualsHeader=true >}} +{{< badge-examples >}} + {{< tab header="Java" >}} + import org.openqa.selenium.By; + WebDriver driver = new ChromeDriver(); + driver.findElement(By.className("information")); + {{< /tab >}} + {{< tab header="Python" >}} + from selenium.webdriver.common.by import By + driver = webdriver.Chrome() + driver.find_element(By.CLASS_NAME, "information") + {{< /tab >}} + {{< tab header="CSharp" >}} + var driver = new ChromeDriver(); + driver.FindElement(By.ClassName("information")); + {{< /tab >}} + {{< tab header="Ruby" text=true >}} +{{< gh-codeblock path="examples/ruby/spec/elements/locators_spec.rb#L7" >}} + {{< /tab >}} + {{< tab header="JavaScript" >}} + let driver = await new Builder().forBrowser('chrome').build(); + const loc = await driver.findElement(By.className('information')); + {{< /tab >}} + {{< tab header="Kotlin" >}} + import org.openqa.selenium.By + val driver = ChromeDriver() + val loc: WebElement = driver.findElement(By.className("information")) + {{< /tab >}} +{{< /tabpane >}} ## Relative Locators