Skip to content

Commit 32215dc

Browse files
committed
Update the other languages for locators python docs
1 parent 297b5cc commit 32215dc

File tree

3 files changed

+90
-120
lines changed

3 files changed

+90
-120
lines changed

Diff for: website_and_docs/content/documentation/webdriver/elements/locators.ja.md

+30-40
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ available in Selenium.
7878
WebDriver driver = new ChromeDriver();
7979
driver.findElement(By.className("information"));
8080
{{< /tab >}}
81-
{{< tab header="Python" >}}
82-
driver = webdriver.Chrome()
83-
driver.find_element(By.CLASS_NAME, "information")
81+
{{< tab header="Python" text=true >}}
82+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
8483
{{< /tab >}}
8584
{{< tab header="CSharp" >}}
8685
var driver = new ChromeDriver();
@@ -111,9 +110,8 @@ textbox, using css.
111110
WebDriver driver = new ChromeDriver();
112111
driver.findElement(By.cssSelector("#fname"));
113112
{{< /tab >}}
114-
{{< tab header="Python" >}}
115-
driver = webdriver.Chrome()
116-
driver.find_element(By.CSS_SELECTOR, "#fname")
113+
{{< tab header="Python" text=true >}}
114+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L18" >}}
117115
{{< /tab >}}
118116
{{< tab header="CSharp" >}}
119117
var driver = new ChromeDriver();
@@ -142,9 +140,8 @@ We will identify the Last Name field using it.
142140
WebDriver driver = new ChromeDriver();
143141
driver.findElement(By.id("lname"));
144142
{{< /tab >}}
145-
{{< tab header="Python" >}}
146-
driver = webdriver.Chrome()
147-
driver.find_element(By.ID, "lname")
143+
{{< tab header="Python" text=true >}}
144+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L26" >}}
148145
{{< /tab >}}
149146
{{< tab header="CSharp" >}}
150147
var driver = new ChromeDriver();
@@ -174,9 +171,8 @@ We will identify the Newsletter checkbox using it.
174171
WebDriver driver = new ChromeDriver();
175172
driver.findElement(By.name("newsletter"));
176173
{{< /tab >}}
177-
{{< tab header="Python" >}}
178-
driver = webdriver.Chrome()
179-
driver.find_element(By.NAME, "newsletter")
174+
{{< tab header="Python" text=true >}}
175+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L34" >}}
180176
{{< /tab >}}
181177
{{< tab header="CSharp" >}}
182178
var driver = new ChromeDriver();
@@ -204,9 +200,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
204200
WebDriver driver = new ChromeDriver();
205201
driver.findElement(By.linkText("Selenium Official Page"));
206202
{{< /tab >}}
207-
{{< tab header="Python" >}}
208-
driver = webdriver.Chrome()
209-
driver.find_element(By.LINK_TEXT, "Selenium Official Page")
203+
{{< tab header="Python" text=true >}}
204+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L42" >}}
210205
{{< /tab >}}
211206
{{< tab header="CSharp" >}}
212207
var driver = new ChromeDriver();
@@ -235,9 +230,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
235230
WebDriver driver = new ChromeDriver();
236231
driver.findElement(By.partialLinkText("Official Page"));
237232
{{< /tab >}}
238-
{{< tab header="Python" >}}
239-
driver = webdriver.Chrome()
240-
driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page")
233+
{{< tab header="Python" text=true >}}
234+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L50" >}}
241235
{{< /tab >}}
242236
{{< tab header="CSharp" >}}
243237
var driver = new ChromeDriver();
@@ -264,9 +258,8 @@ From the above HTML snippet shared, lets identify the link, using its html tag "
264258
WebDriver driver = new ChromeDriver();
265259
driver.findElement(By.tagName("a"));
266260
{{< /tab >}}
267-
{{< tab header="Python" >}}
268-
driver = webdriver.Chrome()
269-
driver.find_element(By.TAG_NAME, "a")
261+
{{< tab header="Python" text=true >}}
262+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L58" >}}
270263
{{< /tab >}}
271264
{{< tab header="CSharp" >}}
272265
var driver = new ChromeDriver();
@@ -299,9 +292,8 @@ first name text box. Let us create locator for female radio button using xpath.
299292
WebDriver driver = new ChromeDriver();
300293
driver.findElement(By.xpath("//input[@value='f']"));
301294
{{< /tab >}}
302-
{{< tab header="Python" >}}
303-
driver = webdriver.Chrome()
304-
driver.find_element(By.XPATH, "//input[@value='f']")
295+
{{< tab header="Python" text=true >}}
296+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L66" >}}
305297
{{< /tab >}}
306298
{{< tab header="CSharp" >}}
307299
var driver = new ChromeDriver();
@@ -335,10 +327,8 @@ others it's as simple as setting a parameter in the FindElement function
335327
WebDriver driver = new ChromeDriver();
336328
driver.findElement(By.className("information"));
337329
{{< /tab >}}
338-
{{< tab header="Python" >}}
339-
from selenium.webdriver.common.by import By
340-
driver = webdriver.Chrome()
341-
driver.find_element(By.CLASS_NAME, "information")
330+
{{< tab header="Python" text=true >}}
331+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
342332
{{< /tab >}}
343333
{{< tab header="CSharp" >}}
344334
var driver = new ChromeDriver();
@@ -445,8 +435,8 @@ we can locate the text field element using the fact that it is an "input" elemen
445435
{{< tab header="Java" >}}
446436
By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
447437
{{< /tab >}}
448-
{{< tab header="Python" >}}
449-
email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"})
438+
{{< tab header="Python" text=true >}}
439+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L75" >}}
450440
{{< /tab >}}
451441
{{< tab header="CSharp" >}}
452442
var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password"));
@@ -471,8 +461,8 @@ we can locate the text field element using the fact that it is an "input" elemen
471461
{{< tab header="Java" >}}
472462
By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
473463
{{< /tab >}}
474-
{{< tab header="Python" >}}
475-
password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"})
464+
{{< tab header="Python" text=true >}}
465+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L77" >}}
476466
{{< /tab >}}
477467
{{< tab header="CSharp" >}}
478468
var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email"));
@@ -497,8 +487,8 @@ we can locate the cancel button element using the fact that it is a "button" ele
497487
{{< tab header="Java" >}}
498488
By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
499489
{{< /tab >}}
500-
{{< tab header="Python" >}}
501-
cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"})
490+
{{< tab header="Python" text=true >}}
491+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L79" >}}
502492
{{< /tab >}}
503493
{{< tab header="CSharp" >}}
504494
var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit"));
@@ -523,8 +513,8 @@ we can locate the submit button element using the fact that it is a "button" ele
523513
{{< tab header="Java" >}}
524514
By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
525515
{{< /tab >}}
526-
{{< tab header="Python" >}}
527-
submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel"})
516+
{{< tab header="Python" text=true >}}
517+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L81" >}}
528518
{{< /tab >}}
529519
{{< tab header="CSharp" >}}
530520
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel"));
@@ -551,8 +541,8 @@ but its associated [input label element](https://developer.mozilla.org/en-US/doc
551541
{{< tab header="Java" >}}
552542
By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
553543
{{< /tab >}}
554-
{{< tab header="Python" >}}
555-
email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"})
544+
{{< tab header="Python" text=true >}}
545+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L83" >}}
556546
{{< /tab >}}
557547
{{< tab header="CSharp" >}}
558548
var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email"));
@@ -576,8 +566,8 @@ You can also chain locators if needed. Sometimes the element is most easily iden
576566
{{< tab header="Java" >}}
577567
By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
578568
{{< /tab >}}
579-
{{< tab header="Python" >}}
580-
submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_right_of({By.ID: "cancel"})
569+
{{< tab header="Python" text=true >}}
570+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L85" >}}
581571
{{< /tab >}}
582572
{{< tab header="CSharp" >}}
583573
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));

Diff for: website_and_docs/content/documentation/webdriver/elements/locators.pt-br.md

+30-40
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,8 @@ available in Selenium.
8181
WebDriver driver = new ChromeDriver();
8282
driver.findElement(By.className("information"));
8383
{{< /tab >}}
84-
{{< tab header="Python" >}}
85-
driver = webdriver.Chrome()
86-
driver.find_element(By.CLASS_NAME, "information")
84+
{{< tab header="Python" text=true >}}
85+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
8786
{{< /tab >}}
8887
{{< tab header="CSharp" >}}
8988
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();
@@ -145,9 +143,8 @@ We will identify the Last Name field using it.
145143
WebDriver driver = new ChromeDriver();
146144
driver.findElement(By.id("lname"));
147145
{{< /tab >}}
148-
{{< tab header="Python" >}}
149-
driver = webdriver.Chrome()
150-
driver.find_element(By.ID, "lname")
146+
{{< tab header="Python" text=true >}}
147+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L26" >}}
151148
{{< /tab >}}
152149
{{< tab header="CSharp" >}}
153150
var driver = new ChromeDriver();
@@ -177,9 +174,8 @@ We will identify the Newsletter checkbox using it.
177174
WebDriver driver = new ChromeDriver();
178175
driver.findElement(By.name("newsletter"));
179176
{{< /tab >}}
180-
{{< tab header="Python" >}}
181-
driver = webdriver.Chrome()
182-
driver.find_element(By.NAME, "newsletter")
177+
{{< tab header="Python" text=true >}}
178+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L34" >}}
183179
{{< /tab >}}
184180
{{< tab header="CSharp" >}}
185181
var driver = new ChromeDriver();
@@ -207,9 +203,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
207203
WebDriver driver = new ChromeDriver();
208204
driver.findElement(By.linkText("Selenium Official Page"));
209205
{{< /tab >}}
210-
{{< tab header="Python" >}}
211-
driver = webdriver.Chrome()
212-
driver.find_element(By.LINK_TEXT, "Selenium Official Page")
206+
{{< tab header="Python" text=true >}}
207+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L42" >}}
213208
{{< /tab >}}
214209
{{< tab header="CSharp" >}}
215210
var driver = new ChromeDriver();
@@ -238,9 +233,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
238233
WebDriver driver = new ChromeDriver();
239234
driver.findElement(By.partialLinkText("Official Page"));
240235
{{< /tab >}}
241-
{{< tab header="Python" >}}
242-
driver = webdriver.Chrome()
243-
driver.find_element(By.PARTIAL_LINK_TEXT, "Official Page")
236+
{{< tab header="Python" text=true >}}
237+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L50" >}}
244238
{{< /tab >}}
245239
{{< tab header="CSharp" >}}
246240
var driver = new ChromeDriver();
@@ -267,9 +261,8 @@ From the above HTML snippet shared, lets identify the link, using its html tag "
267261
WebDriver driver = new ChromeDriver();
268262
driver.findElement(By.tagName("a"));
269263
{{< /tab >}}
270-
{{< tab header="Python" >}}
271-
driver = webdriver.Chrome()
272-
driver.find_element(By.TAG_NAME, "a")
264+
{{< tab header="Python" text=true >}}
265+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L58" >}}
273266
{{< /tab >}}
274267
{{< tab header="CSharp" >}}
275268
var driver = new ChromeDriver();
@@ -302,9 +295,8 @@ first name text box. Let us create locator for female radio button using xpath.
302295
WebDriver driver = new ChromeDriver();
303296
driver.findElement(By.xpath("//input[@value='f']"));
304297
{{< /tab >}}
305-
{{< tab header="Python" >}}
306-
driver = webdriver.Chrome()
307-
driver.find_element(By.XPATH, "//input[@value='f']")
298+
{{< tab header="Python" text=true >}}
299+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L66" >}}
308300
{{< /tab >}}
309301
{{< tab header="CSharp" >}}
310302
var driver = new ChromeDriver();
@@ -338,10 +330,8 @@ others it's as simple as setting a parameter in the FindElement function
338330
WebDriver driver = new ChromeDriver();
339331
driver.findElement(By.className("information"));
340332
{{< /tab >}}
341-
{{< tab header="Python" >}}
342-
from selenium.webdriver.common.by import By
343-
driver = webdriver.Chrome()
344-
driver.find_element(By.CLASS_NAME, "information")
333+
{{< tab header="Python" text=true >}}
334+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L10" >}}
345335
{{< /tab >}}
346336
{{< tab header="CSharp" >}}
347337
var driver = new ChromeDriver();
@@ -448,8 +438,8 @@ we can locate the text field element using the fact that it is an "input" elemen
448438
{{< tab header="Java" >}}
449439
By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
450440
{{< /tab >}}
451-
{{< tab header="Python" >}}
452-
email_locator = locate_with(By.TAG_NAME, "input").above({By.ID: "password"})
441+
{{< tab header="Python" text=true >}}
442+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L75" >}}
453443
{{< /tab >}}
454444
{{< tab header="CSharp" >}}
455445
var emailLocator = RelativeBy.WithLocator(By.TagName("input")).Above(By.Id("password"));
@@ -474,8 +464,8 @@ we can locate the text field element using the fact that it is an "input" elemen
474464
{{< tab header="Java" >}}
475465
By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
476466
{{< /tab >}}
477-
{{< tab header="Python" >}}
478-
password_locator = locate_with(By.TAG_NAME, "input").below({By.ID: "email"})
467+
{{< tab header="Python" text=true >}}
468+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L77" >}}
479469
{{< /tab >}}
480470
{{< tab header="CSharp" >}}
481471
var passwordLocator = RelativeBy.WithLocator(By.TagName("input")).Below(By.Id("email"));
@@ -500,8 +490,8 @@ we can locate the cancel button element using the fact that it is a "button" ele
500490
{{< tab header="Java" >}}
501491
By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
502492
{{< /tab >}}
503-
{{< tab header="Python" >}}
504-
cancel_locator = locate_with(By.TAG_NAME, "button").to_left_of({By.ID: "submit"})
493+
{{< tab header="Python" text=true >}}
494+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L79" >}}
505495
{{< /tab >}}
506496
{{< tab header="CSharp" >}}
507497
var cancelLocator = RelativeBy.WithLocator(By.tagName("button")).LeftOf(By.Id("submit"));
@@ -526,8 +516,8 @@ we can locate the submit button element using the fact that it is a "button" ele
526516
{{< tab header="Java" >}}
527517
By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
528518
{{< /tab >}}
529-
{{< tab header="Python" >}}
530-
submit_locator = locate_with(By.TAG_NAME, "button").to_right_of({By.ID: "cancel"})
519+
{{< tab header="Python" text=true >}}
520+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L81" >}}
531521
{{< /tab >}}
532522
{{< tab header="CSharp" >}}
533523
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).RightOf(By.Id("cancel"));
@@ -554,8 +544,8 @@ but its associated [input label element](https://developer.mozilla.org/en-US/doc
554544
{{< tab header="Java" >}}
555545
By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
556546
{{< /tab >}}
557-
{{< tab header="Python" >}}
558-
email_locator = locate_with(By.TAG_NAME, "input").near({By.ID: "lbl-email"})
547+
{{< tab header="Python" text=true >}}
548+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L83" >}}
559549
{{< /tab >}}
560550
{{< tab header="CSharp" >}}
561551
var emailLocator = RelativeBy.WithLocator(By.tagName("input")).Near(By.Id("lbl-email"));
@@ -579,8 +569,8 @@ You can also chain locators if needed. Sometimes the element is most easily iden
579569
{{< tab header="Java" >}}
580570
By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
581571
{{< /tab >}}
582-
{{< tab header="Python" >}}
583-
submit_locator = locate_with(By.TAG_NAME, "button").below({By.ID: "email"}).to_right_of({By.ID: "cancel"})
572+
{{< tab header="Python" text=true >}}
573+
{{< gh-codeblock path="examples/python/tests/elements/test_locators.py#L85" >}}
584574
{{< /tab >}}
585575
{{< tab header="CSharp" >}}
586576
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));

0 commit comments

Comments
 (0)