Skip to content

Commit c80c792

Browse files
committed
Remove and add examples
1 parent ab43019 commit c80c792

File tree

2 files changed

+30
-59
lines changed

2 files changed

+30
-59
lines changed

examples/python/tests/elements/test_locators.py

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,3 @@ def find_by_relative_locators():
8484

8585
submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_right_of({By.ID: "cancel"})
8686

87-
88-
# def test_find_by_relative_locators():
89-
# driver = webdriver.Chrome()
90-
# driver.get("https://www.selenium.dev/selenium/web/formPage.html")
91-
92-
# locate_with(By.TAG_NAME, "input").above({ By.ID: "checkedchecky" })
93-
94-
# locate_with(By.TAG_NAME, "input").below({ By.ID: "checkedchecky" })
95-
96-
# locate_with(By.TAG_NAME, "select").to_left_of({ By.ID: "multi" })
97-
98-
# locate_with(By.TAG_NAME, "select").to_right_of({ By.NAME: "no-select" })
99-
100-
# locate_with(By.TAG_NAME, "p").near({By.ID: "lone_disabled_selected_radio"})
101-
102-
# locate_with(By.TAG_NAME, "select").to_right_of({ By.NAME: "no-select" }).below({ By.TAG_NAME: "form" })
103-
104-
# driver.quit()
105-

website_and_docs/content/documentation/webdriver/elements/locators.en.md

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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();
@@ -343,10 +335,8 @@ others it's as simple as setting a parameter in the FindElement function
343335
WebDriver driver = new ChromeDriver();
344336
driver.findElement(By.className("information"));
345337
{{< /tab >}}
346-
{{< tab header="Python" >}}
347-
from selenium.webdriver.common.by import By
348-
driver = webdriver.Chrome()
349-
driver.find_element(By.CLASS_NAME, "information")
338+
{{< tab header="Python" text=true >}}
339+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
350340
{{< /tab >}}
351341
{{< tab header="CSharp" >}}
352342
var driver = new ChromeDriver();
@@ -399,8 +389,8 @@ we can locate the text field element using the fact that it is an "input" elemen
399389
{{< tab header="Java" >}}
400390
By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
401391
{{< /tab >}}
402-
{{< tab header="Python" >}}
403-
email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"})
392+
{{< tab header="Python" text=true >}}
393+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L75" >}}
404394
{{< /tab >}}
405395
{{< tab header="CSharp" >}}
406396
var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password"));
@@ -426,8 +416,8 @@ we can locate the text field element using the fact that it is an "input" elemen
426416
{{< tab header="Java" >}}
427417
By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
428418
{{< /tab >}}
429-
{{< tab header="Python" >}}
430-
password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"})
419+
{{< tab header="Python" text=true >}}
420+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L77" >}}
431421
{{< /tab >}}
432422
{{< tab header="CSharp" >}}
433423
var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email"));
@@ -453,8 +443,8 @@ we can locate the cancel button element using the fact that it is a "button" ele
453443
{{< tab header="Java" >}}
454444
By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
455445
{{< /tab >}}
456-
{{< tab header="Python" >}}
457-
cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"})
446+
{{< tab header="Python" text=true >}}
447+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L79" >}}
458448
{{< /tab >}}
459449
{{< tab header="CSharp" >}}
460450
var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit"));
@@ -480,8 +470,8 @@ we can locate the submit button element using the fact that it is a "button" ele
480470
{{< tab header="Java" >}}
481471
By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
482472
{{< /tab >}}
483-
{{< tab header="Python" >}}
484-
submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel"})
473+
{{< tab header="Python" text=true >}}
474+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L81" >}}
485475
{{< /tab >}}
486476
{{< tab header="CSharp" >}}
487477
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel"));
@@ -509,8 +499,8 @@ but its associated [input label element](https://developer.mozilla.org/en-US/doc
509499
{{< tab header="Java" >}}
510500
By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
511501
{{< /tab >}}
512-
{{< tab header="Python" >}}
513-
email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"})
502+
{{< tab header="Python" text=true >}}
503+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L83" >}}
514504
{{< /tab >}}
515505
{{< tab header="CSharp" >}}
516506
var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email"));
@@ -535,8 +525,8 @@ You can also chain locators if needed. Sometimes the element is most easily iden
535525
{{< tab header="Java" >}}
536526
By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
537527
{{< /tab >}}
538-
{{< tab header="Python" >}}
539-
submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_right_of({By.ID: "cancel"})
528+
{{< tab header="Python" text=true >}}
529+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L85" >}}
540530
{{< /tab >}}
541531
{{< tab header="CSharp" >}}
542532
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));

0 commit comments

Comments
 (0)