@@ -80,9 +80,8 @@ available in Selenium.
80
80
WebDriver driver = new ChromeDriver();
81
81
driver.findElement(By.className("information"));
82
82
{{< /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" >}}
86
85
{{< /tab >}}
87
86
{{< tab header="CSharp" >}}
88
87
var driver = new ChromeDriver();
@@ -114,9 +113,8 @@ textbox, using css.
114
113
WebDriver driver = new ChromeDriver();
115
114
driver.findElement(By.cssSelector("#fname"));
116
115
{{< /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" >}}
120
118
{{< /tab >}}
121
119
{{< tab header="CSharp" >}}
122
120
var driver = new ChromeDriver();
@@ -146,9 +144,8 @@ We will identify the Last Name field using it.
146
144
WebDriver driver = new ChromeDriver();
147
145
driver.findElement(By.id("lname"));
148
146
{{< /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" >}}
152
149
{{< /tab >}}
153
150
{{< tab header="CSharp" >}}
154
151
var driver = new ChromeDriver();
@@ -179,9 +176,8 @@ We will identify the Newsletter checkbox using it.
179
176
WebDriver driver = new ChromeDriver();
180
177
driver.findElement(By.name("newsletter"));
181
178
{{< /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" >}}
185
181
{{< /tab >}}
186
182
{{< tab header="CSharp" >}}
187
183
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
210
206
WebDriver driver = new ChromeDriver();
211
207
driver.findElement(By.linkText("Selenium Official Page"));
212
208
{{< /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" >}}
216
211
{{< /tab >}}
217
212
{{< tab header="CSharp" >}}
218
213
var driver = new ChromeDriver();
@@ -242,9 +237,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
242
237
WebDriver driver = new ChromeDriver();
243
238
driver.findElement(By.partialLinkText("Official Page"));
244
239
{{< /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" >}}
248
242
{{< /tab >}}
249
243
{{< tab header="CSharp" >}}
250
244
var driver = new ChromeDriver();
@@ -272,9 +266,8 @@ From the above HTML snippet shared, lets identify the link, using its html tag "
272
266
WebDriver driver = new ChromeDriver();
273
267
driver.findElement(By.tagName("a"));
274
268
{{< /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" >}}
278
271
{{< /tab >}}
279
272
{{< tab header="CSharp" >}}
280
273
var driver = new ChromeDriver();
@@ -308,9 +301,8 @@ first name text box. Let us create locator for female radio button using xpath.
308
301
WebDriver driver = new ChromeDriver();
309
302
driver.findElement(By.xpath("//input[ @value ='f'] "));
310
303
{{< /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" >}}
314
306
{{< /tab >}}
315
307
{{< tab header="CSharp" >}}
316
308
var driver = new ChromeDriver();
@@ -345,10 +337,8 @@ others it's as simple as setting a parameter in the FindElement function
345
337
WebDriver driver = new ChromeDriver();
346
338
driver.findElement(By.className("information"));
347
339
{{< /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" >}}
352
342
{{< /tab >}}
353
343
{{< tab header="CSharp" >}}
354
344
var driver = new ChromeDriver();
@@ -454,8 +444,8 @@ we can locate the text field element using the fact that it is an "input" elemen
454
444
{{< tab header="Java" >}}
455
445
By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
456
446
{{< /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" >}}
459
449
{{< /tab >}}
460
450
{{< tab header="CSharp" >}}
461
451
var 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
481
471
{{< tab header="Java" >}}
482
472
By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
483
473
{{< /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" >}}
486
476
{{< /tab >}}
487
477
{{< tab header="CSharp" >}}
488
478
var 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
508
498
{{< tab header="Java" >}}
509
499
By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
510
500
{{< /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" >}}
513
503
{{< /tab >}}
514
504
{{< tab header="CSharp" >}}
515
505
var 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
535
525
{{< tab header="Java" >}}
536
526
By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
537
527
{{< /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" >}}
540
530
{{< /tab >}}
541
531
{{< tab header="CSharp" >}}
542
532
var 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
564
554
{{< tab header="Java" >}}
565
555
By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
566
556
{{< /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" >}}
569
559
{{< /tab >}}
570
560
{{< tab header="CSharp" >}}
571
561
var 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
590
580
{{< tab header="Java" >}}
591
581
By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
592
582
{{< /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" >}}
595
585
{{< /tab >}}
596
586
{{< tab header="CSharp" >}}
597
587
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));
0 commit comments