Skip to content

Instantly share code, notes, and snippets.

@seleniumgists
Created August 18, 2020 21:36
Show Gist options
  • Save seleniumgists/ff5be40a009a22b4f72f7eec68896d62 to your computer and use it in GitHub Desktop.
Save seleniumgists/ff5be40a009a22b4f72f7eec68896d62 to your computer and use it in GitHub Desktop.
generated automatically from #selenium on seleniumhq slack
# Generated by Selenium IDE
from selenium import webdriver
from <http://selenium.webdriver.common.by|selenium.webdriver.common.by> import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import unittest
from time import sleep
class _TestUntitled(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.vars = {}
def test(self):
driver = self.driver
driver.get("<https://www.selenium.dev/>")
original_window = driver.current_window_handle
assert len(driver.window_handles) == 1
driver.find_element(By.LINK_TEXT, "The Equal Justice Initiative").click()
WebDriverWait(driver, 60).until(EC.number_of_windows_to_be(2))
for window_handle in driver.window_handles:
if window_handle != original_window:
driver.switch_to.window(window_handle)
break
sleep(10)
print(driver.title)
WebDriverWait(driver, 60).until(EC.title_contains("Donate"))
def tearDown(self):
self.driver.close()
if __name__ == "__main__":
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment