Last active
September 16, 2017 07:00
-
-
Save hjwp/208d865c6888dffecf423757359b52d1 to your computer and use it in GitHub Desktop.
selenium alert dismiss repro attempt
This file contains hidden or 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
geckodriver.log |
This file contains hidden or 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
<html> | |
<head> | |
<script> | |
window.onbeforeunload = function (e) { return 'leaving page warning'; }; | |
</script> | |
</head> | |
<body> | |
<h1>Hello World</h1> | |
</body> | |
</html> |
This file contains hidden or 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
#!/usr/bin/env python3.6 | |
import unittest | |
import subprocess | |
from selenium import webdriver | |
class DismissAlertTest(unittest.TestCase): | |
def setUp(self): | |
self.server = subprocess.Popen([ | |
'python', '-m', 'http.server', '8181' | |
]) | |
def tearDown(self): | |
self.server.kill() | |
def test_dismissing_alert(self): | |
browser = webdriver.Firefox() | |
browser.get('http://localhost:8181/') | |
self.assertIn('hello', browser.find_element_by_tag_name('body').text.lower()) | |
browser.refresh() | |
browser.switch_to.alert.accept | |
browser.quit() | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment