@@ -80,9 +80,8 @@ available in Selenium.
8080 WebDriver driver = new ChromeDriver();
8181 driver.findElement(By.className("information"));
8282 {{< /tab >}}
83- {{< tab header="Python" >}}
84- driver = webdriver.Chrome()
85- driver.find_element(By.CLASS_NAME, "information")
83+ {{< tab header="Python" text=true >}}
84+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
8685 {{< /tab >}}
8786 {{< tab header="CSharp" >}}
8887 var driver = new ChromeDriver();
@@ -114,9 +113,8 @@ textbox, using css.
114113 WebDriver driver = new ChromeDriver();
115114 driver.findElement(By.cssSelector("#fname"));
116115 {{< /tab >}}
117- {{< tab header="Python" >}}
118- driver = webdriver.Chrome()
119- driver.find_element(By.CSS_SELECTOR, "#fname")
116+ {{< tab header="Python" text=true >}}
117+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L18" >}}
120118 {{< /tab >}}
121119 {{< tab header="CSharp" >}}
122120 var driver = new ChromeDriver();
@@ -146,9 +144,8 @@ We will identify the Last Name field using it.
146144 WebDriver driver = new ChromeDriver();
147145 driver.findElement(By.id("lname"));
148146 {{< /tab >}}
149- {{< tab header="Python" >}}
150- driver = webdriver.Chrome()
151- driver.find_element(By.ID, "lname")
147+ {{< tab header="Python" text=true >}}
148+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L26" >}}
152149 {{< /tab >}}
153150 {{< tab header="CSharp" >}}
154151 var driver = new ChromeDriver();
@@ -179,9 +176,8 @@ We will identify the Newsletter checkbox using it.
179176 WebDriver driver = new ChromeDriver();
180177 driver.findElement(By.name("newsletter"));
181178 {{< /tab >}}
182- {{< tab header="Python" >}}
183- driver = webdriver.Chrome()
184- driver.find_element(By.NAME, "newsletter")
179+ {{< tab header="Python" text=true >}}
180+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L34" >}}
185181 {{< /tab >}}
186182 {{< tab header="CSharp" >}}
187183 var driver = new ChromeDriver();
@@ -210,9 +206,8 @@ In the HTML snippet shared, we have a link available, let's see how will we loca
210206 WebDriver driver = new ChromeDriver();
211207 driver.findElement(By.linkText("Selenium Official Page"));
212208 {{< /tab >}}
213- {{< tab header="Python" >}}
214- driver = webdriver.Chrome()
215- driver.find_element(By.LINK_TEXT, "Selenium Official Page")
209+ {{< tab header="Python" text=true >}}
210+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L42" >}}
216211 {{< /tab >}}
217212 {{< tab header="CSharp" >}}
218213 var driver = new ChromeDriver();
@@ -242,9 +237,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
242237 WebDriver driver = new ChromeDriver();
243238 driver.findElement(By.partialLinkText("Official Page"));
244239 {{< /tab >}}
245- {{< tab header="Python" >}}
246- driver = webdriver.Chrome()
247- driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page")
240+ {{< tab header="Python" text=true >}}
241+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L50" >}}
248242 {{< /tab >}}
249243 {{< tab header="CSharp" >}}
250244 var driver = new ChromeDriver();
@@ -272,9 +266,8 @@ From the above HTML snippet shared, lets identify the link, using its html tag "
272266 WebDriver driver = new ChromeDriver();
273267 driver.findElement(By.tagName("a"));
274268 {{< /tab >}}
275- {{< tab header="Python" >}}
276- driver = webdriver.Chrome()
277- driver.find_element(By.TAG_NAME, "a")
269+ {{< tab header="Python" text=true >}}
270+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L58" >}}
278271 {{< /tab >}}
279272 {{< tab header="CSharp" >}}
280273 var driver = new ChromeDriver();
@@ -308,9 +301,8 @@ first name text box. Let us create locator for female radio button using xpath.
308301 WebDriver driver = new ChromeDriver();
309302 driver.findElement(By.xpath("//input[ @value ='f'] "));
310303 {{< /tab >}}
311- {{< tab header="Python" >}}
312- driver = webdriver.Chrome()
313- driver.find_element(By.XPATH, "//input[ @value ='f'] ")
304+ {{< tab header="Python" text=true >}}
305+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L66" >}}
314306 {{< /tab >}}
315307 {{< tab header="CSharp" >}}
316308 var driver = new ChromeDriver();
@@ -345,10 +337,8 @@ others it's as simple as setting a parameter in the FindElement function
345337 WebDriver driver = new ChromeDriver();
346338 driver.findElement(By.className("information"));
347339 {{< /tab >}}
348- {{< tab header="Python" >}}
349- from selenium.webdriver.common.by import By
350- driver = webdriver.Chrome()
351- driver.find_element(By.CLASS_NAME, "information")
340+ {{< tab header="Python" text=true >}}
341+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
352342 {{< /tab >}}
353343 {{< tab header="CSharp" >}}
354344 var driver = new ChromeDriver();
@@ -454,8 +444,8 @@ we can locate the text field element using the fact that it is an "input" elemen
454444{{< tab header="Java" >}}
455445By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
456446{{< /tab >}}
457- {{< tab header="Python" >}}
458- email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"})
447+ {{< tab header="Python" text=true >}}
448+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L75" >}}
459449{{< /tab >}}
460450{{< tab header="CSharp" >}}
461451var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password"));
@@ -481,8 +471,8 @@ we can locate the text field element using the fact that it is an "input" elemen
481471{{< tab header="Java" >}}
482472By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
483473{{< /tab >}}
484- {{< tab header="Python" >}}
485- password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"})
474+ {{< tab header="Python" text=true >}}
475+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L77" >}}
486476{{< /tab >}}
487477{{< tab header="CSharp" >}}
488478var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email"));
@@ -508,8 +498,8 @@ we can locate the cancel button element using the fact that it is a "button" ele
508498{{< tab header="Java" >}}
509499By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
510500{{< /tab >}}
511- {{< tab header="Python" >}}
512- cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"})
501+ {{< tab header="Python" text=true >}}
502+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L79" >}}
513503{{< /tab >}}
514504{{< tab header="CSharp" >}}
515505var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit"));
@@ -535,8 +525,8 @@ we can locate the submit button element using the fact that it is a "button" ele
535525{{< tab header="Java" >}}
536526By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
537527{{< /tab >}}
538- {{< tab header="Python" >}}
539- submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel"})
528+ {{< tab header="Python" text=true >}}
529+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L81" >}}
540530{{< /tab >}}
541531{{< tab header="CSharp" >}}
542532var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel"));
@@ -564,8 +554,8 @@ but its associated [input label element](https://developer.mozilla.org/en-US/doc
564554{{< tab header="Java" >}}
565555By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
566556{{< /tab >}}
567- {{< tab header="Python" >}}
568- email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"})
557+ {{< tab header="Python" text=true >}}
558+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L83" >}}
569559{{< /tab >}}
570560{{< tab header="CSharp" >}}
571561var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email"));
@@ -590,8 +580,8 @@ You can also chain locators if needed. Sometimes the element is most easily iden
590580{{< tab header="Java" >}}
591581By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
592582{{< /tab >}}
593- {{< tab header="Python" >}}
594- submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_right_of({By.ID: "cancel"})
583+ {{< tab header="Python" text=true >}}
584+ {{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L85" >}}
595585{{< /tab >}}
596586{{< tab header="CSharp" >}}
597587var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));
0 commit comments