1717
1818import pytest
1919
20+ from selenium import webdriver
21+ from selenium .webdriver .firefox .options import Options
2022from selenium .webdriver .remote .locator_converter import LocatorConverter
2123
2224
@@ -28,18 +30,28 @@ def convert(self, by, value):
2830 return super ().convert (by , value )
2931
3032
31- @pytest .mark .skip (reason = "Needs to be updated" )
32- def test_find_element_with_custom_locator (driver ):
33- driver .get ("data:text/html,<div custom-attr='example'>Test</div>" )
34- element = driver .find_element ("custom" , "example" )
33+ @pytest .fixture ()
34+ def custom_locator_driver (headless ):
35+ options = Options ()
36+ if headless :
37+ options .add_argument ("-headless" )
38+ try :
39+ driver = webdriver .Remote (options = options , locator_converter = CustomLocatorConverter ())
40+ yield driver
41+ finally :
42+ driver .quit ()
43+
44+
45+ def test_find_element_with_custom_locator (custom_locator_driver ):
46+ custom_locator_driver .get ("data:text/html,<div custom-attr='example'>Test</div>" )
47+ element = custom_locator_driver .find_element ("custom" , "example" )
3548 assert element is not None
3649 assert element .text == "Test"
3750
3851
39- @pytest .mark .skip (reason = "Needs to be updated" )
40- def test_find_elements_with_custom_locator (driver ):
41- driver .get ("data:text/html,<div custom-attr='example'>Test1</div><div custom-attr='example'>Test2</div>" )
42- elements = driver .find_elements ("custom" , "example" )
52+ def test_find_elements_with_custom_locator (custom_locator_driver ):
53+ custom_locator_driver .get ("data:text/html,<div custom-attr='example'>Test1</div><div custom-attr='example'>Test2</div>" )
54+ elements = custom_locator_driver .find_elements ("custom" , "example" )
4355 assert len (elements ) == 2
4456 assert elements [0 ].text == "Test1"
4557 assert elements [1 ].text == "Test2"
0 commit comments