Created
June 1, 2020 19:42
-
-
Save barancev/3a2c64b71f2419a2e82835a07eb01e60 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.support.select import Select | |
from selenium.common.exceptions import UnexpectedTagNameException | |
from selenium.webdriver.common.alert import Alert | |
import pytest | |
def test_without_isolation(): | |
wd = webdriver.Chrome() | |
wd.get('https://www.selenium.dev/') | |
element = wd.find_element_by_tag_name('div') | |
try: | |
select = Select(element) | |
assert False | |
except UnexpectedTagNameException: | |
pass | |
def test_with_isolation(mocker): | |
mockElement = mocker.patch('selenium.webdriver.remote.webelement.WebElement') | |
element = mockElement.return_value | |
element.tag_name = 'div' | |
try: | |
select = Select(element) | |
assert False | |
except UnexpectedTagNameException: | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment