@@ -78,9 +78,8 @@ available in Selenium.
78
78
WebDriver driver = new ChromeDriver();
79
79
driver.findElement(By.className("information"));
80
80
{{< /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" >}}
84
83
{{< /tab >}}
85
84
{{< tab header="CSharp" >}}
86
85
var driver = new ChromeDriver();
@@ -111,9 +110,8 @@ textbox, using css.
111
110
WebDriver driver = new ChromeDriver();
112
111
driver.findElement(By.cssSelector("#fname"));
113
112
{{< /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" >}}
117
115
{{< /tab >}}
118
116
{{< tab header="CSharp" >}}
119
117
var driver = new ChromeDriver();
@@ -142,9 +140,8 @@ We will identify the Last Name field using it.
142
140
WebDriver driver = new ChromeDriver();
143
141
driver.findElement(By.id("lname"));
144
142
{{< /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" >}}
148
145
{{< /tab >}}
149
146
{{< tab header="CSharp" >}}
150
147
var driver = new ChromeDriver();
@@ -174,9 +171,8 @@ We will identify the Newsletter checkbox using it.
174
171
WebDriver driver = new ChromeDriver();
175
172
driver.findElement(By.name("newsletter"));
176
173
{{< /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" >}}
180
176
{{< /tab >}}
181
177
{{< tab header="CSharp" >}}
182
178
var driver = new ChromeDriver();
@@ -204,9 +200,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
204
200
WebDriver driver = new ChromeDriver();
205
201
driver.findElement(By.linkText("Selenium Official Page"));
206
202
{{< /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" >}}
210
205
{{< /tab >}}
211
206
{{< tab header="CSharp" >}}
212
207
var driver = new ChromeDriver();
@@ -235,9 +230,8 @@ In the HTML snippet shared, we have a link available, lets see how will we locat
235
230
WebDriver driver = new ChromeDriver();
236
231
driver.findElement(By.partialLinkText("Official Page"));
237
232
{{< /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" >}}
241
235
{{< /tab >}}
242
236
{{< tab header="CSharp" >}}
243
237
var driver = new ChromeDriver();
@@ -264,9 +258,8 @@ From the above HTML snippet shared, lets identify the link, using its html tag "
264
258
WebDriver driver = new ChromeDriver();
265
259
driver.findElement(By.tagName("a"));
266
260
{{< /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" >}}
270
263
{{< /tab >}}
271
264
{{< tab header="CSharp" >}}
272
265
var driver = new ChromeDriver();
@@ -299,9 +292,8 @@ first name text box. Let us create locator for female radio button using xpath.
299
292
WebDriver driver = new ChromeDriver();
300
293
driver.findElement(By.xpath("//input[ @value ='f'] "));
301
294
{{< /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" >}}
305
297
{{< /tab >}}
306
298
{{< tab header="CSharp" >}}
307
299
var driver = new ChromeDriver();
@@ -335,10 +327,8 @@ others it's as simple as setting a parameter in the FindElement function
335
327
WebDriver driver = new ChromeDriver();
336
328
driver.findElement(By.className("information"));
337
329
{{< /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" >}}
342
332
{{< /tab >}}
343
333
{{< tab header="CSharp" >}}
344
334
var driver = new ChromeDriver();
@@ -445,8 +435,8 @@ we can locate the text field element using the fact that it is an "input" elemen
445
435
{{< tab header="Java" >}}
446
436
By emailLocator = RelativeLocator.with(By.tagName("input")).above(By.id("password"));
447
437
{{< /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" >}}
450
440
{{< /tab >}}
451
441
{{< tab header="CSharp" >}}
452
442
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
471
461
{{< tab header="Java" >}}
472
462
By passwordLocator = RelativeLocator.with(By.tagName("input")).below(By.id("email"));
473
463
{{< /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" >}}
476
466
{{< /tab >}}
477
467
{{< tab header="CSharp" >}}
478
468
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
497
487
{{< tab header="Java" >}}
498
488
By cancelLocator = RelativeLocator.with(By.tagName("button")).toLeftOf(By.id("submit"));
499
489
{{< /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" >}}
502
492
{{< /tab >}}
503
493
{{< tab header="CSharp" >}}
504
494
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
523
513
{{< tab header="Java" >}}
524
514
By submitLocator = RelativeLocator.with(By.tagName("button")).toRightOf(By.id("cancel"));
525
515
{{< /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" >}}
528
518
{{< /tab >}}
529
519
{{< tab header="CSharp" >}}
530
520
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
551
541
{{< tab header="Java" >}}
552
542
By emailLocator = RelativeLocator.with(By.tagName("input")).near(By.id("lbl-email"));
553
543
{{< /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" >}}
556
546
{{< /tab >}}
557
547
{{< tab header="CSharp" >}}
558
548
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
576
566
{{< tab header="Java" >}}
577
567
By submitLocator = RelativeLocator.with(By.tagName("button")).below(By.id("email")).toRightOf(By.id("cancel"));
578
568
{{< /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" >}}
581
571
{{< /tab >}}
582
572
{{< tab header="CSharp" >}}
583
573
var submitLocator = RelativeBy.WithLocator(By.tagName("button")).Below(By.Id("email")).RightOf(By.Id("cancel"));
0 commit comments