@@ -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();
@@ -343,10 +335,8 @@ others it's as simple as setting a parameter in the FindElement function
343
335
WebDriver driver = new ChromeDriver();
344
336
driver.findElement(By.className("information"));
345
337
{{< /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" >}}
350
340
{{< /tab >}}
351
341
{{< tab header="CSharp" >}}
352
342
var driver = new ChromeDriver();
@@ -399,8 +389,8 @@ we can locate the text field element using the fact that it is an "input" elemen
399
389
{{< tab header="Java" >}}
400
390
By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
401
391
{{< /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" >}}
404
394
{{< /tab >}}
405
395
{{< tab header="CSharp" >}}
406
396
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
426
416
{{< tab header="Java" >}}
427
417
By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
428
418
{{< /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" >}}
431
421
{{< /tab >}}
432
422
{{< tab header="CSharp" >}}
433
423
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
453
443
{{< tab header="Java" >}}
454
444
By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
455
445
{{< /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" >}}
458
448
{{< /tab >}}
459
449
{{< tab header="CSharp" >}}
460
450
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
480
470
{{< tab header="Java" >}}
481
471
By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
482
472
{{< /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" >}}
485
475
{{< /tab >}}
486
476
{{< tab header="CSharp" >}}
487
477
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
509
499
{{< tab header="Java" >}}
510
500
By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
511
501
{{< /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" >}}
514
504
{{< /tab >}}
515
505
{{< tab header="CSharp" >}}
516
506
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
535
525
{{< tab header="Java" >}}
536
526
By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
537
527
{{< /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" >}}
540
530
{{< /tab >}}
541
531
{{< tab header="CSharp" >}}
542
532
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));
0 commit comments