20
20
from selenium .common .exceptions import InvalidSelectorException , NoSuchElementException
21
21
from selenium .webdriver .common .by import By
22
22
23
- # By.id positive
23
+ # By.ID positive
24
24
25
25
26
26
def test_should_be_able_to_find_asingle_element_by_id (driver , pages ):
@@ -53,7 +53,7 @@ def test_should_be_able_to_find_multiple_elements_by_numeric_id(driver, pages):
53
53
assert len (elements ) == 8
54
54
55
55
56
- # By.id negative
56
+ # By.ID negative
57
57
58
58
59
59
def test_should_not_be_able_to_locate_by_id_asingle_element_that_does_not_exist (driver , pages ):
@@ -99,7 +99,7 @@ def test_no_such_element_error(driver, pages):
99
99
driver .find_element (By .ID , "non_Existent_Button" )
100
100
101
101
102
- # By.name positive
102
+ # By.NAME positive
103
103
104
104
105
105
def test_should_be_able_to_find_asingle_element_by_name (driver , pages ):
@@ -120,7 +120,7 @@ def test_should_be_able_to_find_an_element_that_does_not_support_the_name_proper
120
120
assert element .get_attribute ("name" ) == "div1"
121
121
122
122
123
- # By.name negative
123
+ # By.NAME negative
124
124
125
125
126
126
def test_should_not_be_able_to_locate_by_name_asingle_element_that_does_not_exist (driver , pages ):
@@ -159,7 +159,7 @@ def test_finding_multiple_elements_by_name_with_space_should_return_empty_list(d
159
159
assert len (elements ) == 0
160
160
161
161
162
- # By.tag_Name positive
162
+ # By.TAG_NAME positive
163
163
164
164
165
165
def test_should_be_able_to_find_asingle_element_by_tag_name (driver , pages ):
@@ -174,7 +174,7 @@ def test_should_be_able_to_find_multiple_elements_by_tag_name(driver, pages):
174
174
assert len (elements ) > 1
175
175
176
176
177
- # By.tag_Name negative
177
+ # By.TAG_NAME negative
178
178
179
179
180
180
def test_should_not_be_able_to_locate_by_tag_name_asingle_element_that_does_not_exist (driver , pages ):
@@ -189,22 +189,18 @@ def test_should_not_be_able_to_locate_by_tag_name_multiple_elements_that_do_not_
189
189
assert len (elements ) == 0
190
190
191
191
192
- @pytest .mark .xfail_firefox (reason = "https://github.com/mozilla/geckodriver/issues/2007 " )
193
- @pytest .mark .xfail_remote (reason = "https://github.com/mozilla/geckodriver/issues/2007 " )
192
+ @pytest .mark .xfail_firefox (reason = "unlike chrome, firefox raises NoSuchElementException " )
193
+ @pytest .mark .xfail_remote (reason = "unlike chrome, firefox raises NoSuchElementException " )
194
194
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises NoSuchElementException" )
195
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
196
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
197
195
def test_finding_asingle_element_by_empty_tag_name_should_throw (driver , pages ):
198
196
pages .load ("formPage.html" )
199
197
with pytest .raises (InvalidSelectorException ):
200
198
driver .find_element (By .TAG_NAME , "" )
201
199
202
200
203
- @pytest .mark .xfail_firefox (reason = "https://github.com/mozilla/geckodriver/issues/2007 " )
204
- @pytest .mark .xfail_remote (reason = "https://github.com/mozilla/geckodriver/issues/2007 " )
201
+ @pytest .mark .xfail_firefox (reason = "unlike chrome, firefox returns an empty list " )
202
+ @pytest .mark .xfail_remote (reason = "unlike chrome, firefox returns an empty list " )
205
203
@pytest .mark .xfail_safari (reason = "unlike chrome, safari returns an empty list" )
206
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
207
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
208
204
def test_finding_multiple_elements_by_empty_tag_name_should_throw (driver , pages ):
209
205
pages .load ("formPage.html" )
210
206
with pytest .raises (InvalidSelectorException ):
@@ -223,7 +219,7 @@ def test_finding_multiple_elements_by_tag_name_with_space_should_return_empty_li
223
219
assert len (elements ) == 0
224
220
225
221
226
- # By.class_Name positive
222
+ # By.CLASS_NAME positive
227
223
228
224
229
225
def test_should_be_able_to_find_asingle_element_by_class (driver , pages ):
@@ -269,7 +265,7 @@ def test_should_find_elements_by_class_when_its_name_is_surrounded_by_whitespace
269
265
assert elements [0 ].text == "Spaced out"
270
266
271
267
272
- # By.class_Name negative
268
+ # By.CLASS_NAME negative
273
269
274
270
275
271
def test_should_not_find_element_by_class_when_the_name_queried_is_shorter_than_candidate_name (driver , pages ):
@@ -279,8 +275,6 @@ def test_should_not_find_element_by_class_when_the_name_queried_is_shorter_than_
279
275
280
276
281
277
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
282
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
283
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
284
278
def test_finding_asingle_element_by_empty_class_name_should_throw (driver , pages ):
285
279
pages .load ("xhtmlTest.html" )
286
280
msg = r"\/errors#invalidselectorexception"
@@ -289,8 +283,6 @@ def test_finding_asingle_element_by_empty_class_name_should_throw(driver, pages)
289
283
290
284
291
285
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
292
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
293
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
294
286
def test_finding_multiple_elements_by_empty_class_name_should_throw (driver , pages ):
295
287
pages .load ("xhtmlTest.html" )
296
288
with pytest .raises (InvalidSelectorException ):
@@ -299,29 +291,25 @@ def test_finding_multiple_elements_by_empty_class_name_should_throw(driver, page
299
291
300
292
def test_finding_asingle_element_by_compound_class_name_should_throw (driver , pages ):
301
293
pages .load ("xhtmlTest.html" )
302
- with pytest .raises (NoSuchElementException ):
294
+ with pytest .raises (InvalidSelectorException ):
303
295
driver .find_element (By .CLASS_NAME , "a b" )
304
296
305
297
306
298
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
307
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
308
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
309
299
def test_finding_asingle_element_by_invalid_class_name_should_throw (driver , pages ):
310
300
pages .load ("xhtmlTest.html" )
311
301
with pytest .raises (InvalidSelectorException ):
312
302
driver .find_element (By .CLASS_NAME , "!@#$%^&*" )
313
303
314
304
315
305
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
316
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
317
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
318
306
def test_finding_multiple_elements_by_invalid_class_name_should_throw (driver , pages ):
319
307
pages .load ("xhtmlTest.html" )
320
308
with pytest .raises (InvalidSelectorException ):
321
309
driver .find_elements (By .CLASS_NAME , "!@#$%^&*" )
322
310
323
311
324
- # By.xpath positive
312
+ # By.XPATH positive
325
313
326
314
327
315
def test_should_be_able_to_find_asingle_element_by_xpath (driver , pages ):
@@ -388,7 +376,7 @@ def test_should_be_able_to_find_element_by_xpath_in_xml_document(driver, pages):
388
376
assert "baz" in element .text
389
377
390
378
391
- # By.xpath negative
379
+ # By.XPATH negative
392
380
393
381
394
382
def test_should_throw_an_exception_when_there_is_no_link_to_click (driver , pages ):
@@ -398,8 +386,6 @@ def test_should_throw_an_exception_when_there_is_no_link_to_click(driver, pages)
398
386
399
387
400
388
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
401
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
402
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
403
389
def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_invalid_in_driver_find_element (
404
390
driver , pages
405
391
):
@@ -409,8 +395,6 @@ def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_inv
409
395
410
396
411
397
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
412
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
413
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
414
398
def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_invalid_in_driver_find_elements (
415
399
driver , pages
416
400
):
@@ -420,8 +404,6 @@ def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_inv
420
404
421
405
422
406
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
423
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
424
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
425
407
def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_invalid_in_element_find_element (
426
408
driver , pages
427
409
):
@@ -432,8 +414,6 @@ def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_inv
432
414
433
415
434
416
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
435
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
436
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
437
417
def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_invalid_in_element_find_elements (
438
418
driver , pages
439
419
):
@@ -444,26 +424,20 @@ def test_should_throw_invalid_selector_exception_when_xpath_is_syntactically_inv
444
424
445
425
446
426
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
447
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
448
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
449
427
def test_should_throw_invalid_selector_exception_when_xpath_returns_wrong_type_in_driver_find_element (driver , pages ):
450
428
pages .load ("formPage.html" )
451
429
with pytest .raises (InvalidSelectorException ):
452
430
driver .find_element (By .XPATH , "count(//input)" )
453
431
454
432
455
433
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
456
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
457
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
458
434
def test_should_throw_invalid_selector_exception_when_xpath_returns_wrong_type_in_driver_find_elements (driver , pages ):
459
435
pages .load ("formPage.html" )
460
436
with pytest .raises (InvalidSelectorException ):
461
437
driver .find_elements (By .XPATH , "count(//input)" )
462
438
463
439
464
440
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
465
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
466
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
467
441
def test_should_throw_invalid_selector_exception_when_xpath_returns_wrong_type_in_element_find_element (driver , pages ):
468
442
pages .load ("formPage.html" )
469
443
body = driver .find_element (By .TAG_NAME , "body" )
@@ -472,16 +446,14 @@ def test_should_throw_invalid_selector_exception_when_xpath_returns_wrong_type_i
472
446
473
447
474
448
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
475
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
476
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
477
449
def test_should_throw_invalid_selector_exception_when_xpath_returns_wrong_type_in_element_find_elements (driver , pages ):
478
450
pages .load ("formPage.html" )
479
451
body = driver .find_element (By .TAG_NAME , "body" )
480
452
with pytest .raises (InvalidSelectorException ):
481
453
body .find_elements (By .XPATH , "count(//input)" )
482
454
483
455
484
- # By.css_Selector positive
456
+ # By.CSS_SELECTOR positive
485
457
486
458
487
459
def test_should_be_able_to_find_asingle_element_by_css_selector (driver , pages ):
@@ -530,7 +502,7 @@ def test_should_be_able_to_find_an_element_by_boolean_attribute_using_short_css_
530
502
assert element .get_attribute ("value" ) == "two"
531
503
532
504
533
- # By.css_Selector negative
505
+ # By.CSS_SELECTOR negative
534
506
535
507
536
508
def test_should_not_find_element_by_css_selector_when_there_is_no_such_element (driver , pages ):
@@ -546,42 +518,34 @@ def test_should_not_find_elements_by_css_selector_when_there_is_no_such_element(
546
518
547
519
548
520
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
549
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
550
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
551
521
def test_finding_asingle_element_by_empty_css_selector_should_throw (driver , pages ):
552
522
pages .load ("xhtmlTest.html" )
553
523
with pytest .raises (InvalidSelectorException ):
554
524
driver .find_element (By .CSS_SELECTOR , "" )
555
525
556
526
557
527
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
558
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
559
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
560
528
def test_finding_multiple_elements_by_empty_css_selector_should_throw (driver , pages ):
561
529
pages .load ("xhtmlTest.html" )
562
530
with pytest .raises (InvalidSelectorException ):
563
531
driver .find_elements (By .CSS_SELECTOR , "" )
564
532
565
533
566
534
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
567
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
568
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
569
535
def test_finding_asingle_element_by_invalid_css_selector_should_throw (driver , pages ):
570
536
pages .load ("xhtmlTest.html" )
571
537
with pytest .raises (InvalidSelectorException ):
572
538
driver .find_element (By .CSS_SELECTOR , "//a/b/c[@id='1']" )
573
539
574
540
575
541
@pytest .mark .xfail_safari (reason = "unlike chrome, safari raises TimeoutException" )
576
- @pytest .mark .xfail_chrome (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
577
- @pytest .mark .xfail_edge (reason = "https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743" )
578
542
def test_finding_multiple_elements_by_invalid_css_selector_should_throw (driver , pages ):
579
543
pages .load ("xhtmlTest.html" )
580
544
with pytest .raises (InvalidSelectorException ):
581
545
driver .find_elements (By .CSS_SELECTOR , "//a/b/c[@id='1']" )
582
546
583
547
584
- # By.link_Text positive
548
+ # By.LINK_TEXT positive
585
549
586
550
587
551
def test_should_be_able_to_find_alink_by_text (driver , pages ):
@@ -632,7 +596,7 @@ def test_driver_can_get_link_by_link_test_ignoring_trailing_whitespace(driver, p
632
596
assert link .text == "link with trailing space"
633
597
634
598
635
- # By.link_Text negative
599
+ # By.LINK_TEXT negative
636
600
637
601
638
602
def test_should_not_be_able_to_locate_by_link_text_asingle_element_that_does_not_exist (driver , pages ):
@@ -647,7 +611,7 @@ def test_should_not_be_able_to_locate_by_link_text_multiple_elements_that_do_not
647
611
assert len (elements ) == 0
648
612
649
613
650
- # By.partial_Link_Text positive
614
+ # By.PARTIAL_LINK_TEXT positive
651
615
652
616
653
617
def test_should_be_able_to_find_multiple_elements_by_partial_link_text (driver , pages ):
0 commit comments