Skip to content

Instantly share code, notes, and snippets.

@barancev
Created June 1, 2020 19:42
Show Gist options
  • Save barancev/3a2c64b71f2419a2e82835a07eb01e60 to your computer and use it in GitHub Desktop.
Save barancev/3a2c64b71f2419a2e82835a07eb01e60 to your computer and use it in GitHub Desktop.
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