Skip to content

Commit 6dd16a2

Browse files
committed
use existing driver fixture in tests
1 parent 1087483 commit 6dd16a2

File tree

2 files changed

+2
-27
lines changed

2 files changed

+2
-27
lines changed

py/test/selenium/webdriver/remote/custom_element_tests.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
import pytest
18-
19-
from selenium import webdriver
2017
from selenium.webdriver.common.by import By
2118
from selenium.webdriver.remote.webelement import WebElement
2219

@@ -27,14 +24,6 @@ def custom_method(self):
2724
return "Custom element method"
2825

2926

30-
@pytest.fixture
31-
def driver():
32-
options = webdriver.ChromeOptions()
33-
driver = webdriver.Chrome(options=options)
34-
yield driver
35-
driver.quit()
36-
37-
3827
def test_find_element_with_custom_class(driver, pages):
3928
"""Test to ensure custom element class is used for a single element."""
4029
driver._web_element_cls = MyCustomElement

py/test/selenium/webdriver/remote/remote_custom_locator_tests.py

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17-
import pytest
18-
19-
from selenium import webdriver
2017
from selenium.webdriver.remote.locator_converter import LocatorConverter
21-
from selenium.webdriver.remote.webdriver import WebDriver
2218

2319

2420
class CustomLocatorConverter(LocatorConverter):
@@ -29,24 +25,14 @@ def convert(self, by, value):
2925
return super().convert(by, value)
3026

3127

32-
@pytest.fixture
33-
def driver() -> WebDriver:
34-
options = webdriver.ChromeOptions()
35-
driver = webdriver.Chrome(options=options)
36-
driver.locator_converter = CustomLocatorConverter()
28+
def test_find_element_with_custom_locator(driver):
3729
driver.get("data:text/html,<div custom-attr='example'>Test</div>")
38-
39-
yield driver
40-
driver.quit()
41-
42-
43-
def test_find_element_with_custom_locator(driver: WebDriver) -> None:
4430
element = driver.find_element("custom", "example")
4531
assert element is not None
4632
assert element.text == "Test"
4733

4834

49-
def test_find_elements_with_custom_locator(driver: WebDriver) -> None:
35+
def test_find_elements_with_custom_locator(driver):
5036
driver.get("data:text/html,<div custom-attr='example'>Test1</div><div custom-attr='example'>Test2</div>")
5137
elements = driver.find_elements("custom", "example")
5238
assert len(elements) == 2

0 commit comments

Comments
 (0)