def get_windows_with_url(driver, url):
    """Get a list of existing windows that match the url."""
    windows = []
    for w in driver.window_handles:
        driver.switch_to.window(w)
        if driver.current_window_handle != w:
            # print "target window " + w + " current window " +\
            # driver.current_window_handle
            raise Exception("window handles don't match!")
        # current_url might have a trailing slash on it, so try it both ways
        alt_url = url
        if alt_url[-1] != '/':
            alt_url += '/'
        # print "\tget_windows_with_url " + url + ": looking at " +\
        # driver.current_url
        if driver.current_url == url or driver.current_url == alt_url:
            # print "\tfound a match"
            windows.append(w)
    return windows