Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py] Fix internal error when an unexpected exception is raised while … #4654

Merged
merged 1 commit into from
Nov 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion py/test/selenium/webdriver/common/window_switching_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,19 @@
def close_windows(driver):
main_windows_handle = driver.current_window_handle
yield
for handle in driver.window_handles:
try:
from urllib import request as url_request
URLError = url_request.URLError
except ImportError:
import urllib2 as url_request
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this unnecessary import?

import urllib2
URLError = urllib2.URLError

try:
window_handles = driver.window_handles
except URLError:
return
for handle in window_handles:
if handle != main_windows_handle:
driver.switch_to.window(handle)
driver.close()
Expand Down