def test_handle_prompt_ignore(session, dialog_type): response = execute_async_script(session, "window.{}('Hello');".format(dialog_type)) assert_success(response, None) with pytest.raises(error.UnexpectedAlertOpenException): session.title session.alert.dismiss()
def test_get_current_url_nested_browsing_context(session, create_frame): session.url = "about:blank#wd_from_within_frame" session.switch_frame(create_frame()) result = session.transport.send("GET", "session/%s/url" % session.session_id) assert_success(result, "about:blank#wd_from_within_frame")
def test_set_to_state_cross_realm(session, create_window, state, realmSetting): original_window = session.window_handle session.window_handle = create_window() parameters = { "descriptor": { "name": "geolocation" }, "state": state } parameters.update(realmSetting) response = session.transport.send( "POST", "/session/{session_id}/permissions".format(**vars(session)), parameters ) try: assert_success(response) except AssertionError: # > 4. If parameters.state is an inappropriate permission state for any # > implementation-defined reason, return a WebDriver error with # > WebDriver error code invalid argument. assert_error(response, "invalid argument") return assert response.body.get("value") == None session.window_handle = original_window response = query(session, "geolocation") assert_success(response) result = response.body.get("value") assert isinstance(result, dict) assert result.get("status") == "success" assert result.get("value") == state
def test_send_alert_text(session, page, text): send_response = send_alert_text(session, text) assert_success(send_response) session.alert.accept() assert session.execute_script("return window.result") == text
def test_readonly_element(session): session.url = inline("<input readonly>") element = session.find.css("input", all=False) response = element_send_keys(session, element, "foo") assert_success(response) assert element.property("value") == ""
def test_handle_prompt_accept(session, create_dialog, dialog_type): create_dialog(dialog_type, text="dialog") response = get_window_rect(session) assert_success(response) assert_dialog_handled(session, expected_text="dialog")
def test_transparent_element(session): session.url = inline("""<input style="opacity: 0">""") element = session.find.css("input", all=False) response = element_send_keys(session, element, "foo") assert_success(response) assert element.property("value") == "foo"
def test_history_pushstate(session, url): pushstate_page = inline(""" <script> function pushState() { history.pushState({foo: "bar"}, "", "#pushstate"); } </script> <a onclick="javascript:pushState();">click</a> """) session.url = pushstate_page session.find.css("a", all=False).click() assert session.url == "{}#pushstate".format(pushstate_page) assert session.execute_script("return history.state;") == {"foo": "bar"} session.execute_script(""" let elem = window.document.createElement('div'); window.document.body.appendChild(elem); """) element = session.find.css("div", all=False) response = refresh(session) assert_success(response) assert session.url == "{}#pushstate".format(pushstate_page) assert session.execute_script("return history.state;") == {"foo": "bar"} with pytest.raises(StaleElementReferenceException): element.property("id")
def test_scroll_into_element_view(session): # 14.2 Step 4 session.url = inline("<input type=text value=Federer><div style= \"height: 200vh; width: 5000vh\">") # Scroll to the bottom right of the page session.execute_script("window.scrollTo(document.body.scrollWidth, document.body.scrollHeight);") element = session.find.css("input", all=False) # Clear and scroll back to the top of the page response = clear(session, element) assert_success(response) # Check if element cleared is scrolled into view rect = session.execute_script("return document.getElementsByTagName(\"input\")[0].getBoundingClientRect()") pageDict = {} pageDict["innerHeight"] = session.execute_script("return window.innerHeight") pageDict["innerWidth"] = session.execute_script("return window.innerWidth") pageDict["pageXOffset"] = session.execute_script("return window.pageXOffset") pageDict["pageYOffset"] = session.execute_script("return window.pageYOffset") assert rect["top"] < (pageDict["innerHeight"] + pageDict["pageYOffset"]) and \ rect["left"] < (pageDict["innerWidth"] + pageDict["pageXOffset"]) and \ (rect["top"] + element.rect["height"]) > pageDict["pageYOffset"] and \ (rect["left"] + element.rect["width"]) > pageDict["pageXOffset"]
def test_title_without_element(session): session.url = inline("<h2>Hello</h2>") result = session.transport.send("GET", "session/%s/title" % session.session_id) assert_success(result, read_global(session, "document.title"))
def test_handle_prompt_dismiss(session, dialog_type): response = execute_async_script(session, "window.{}('Hello');".format(dialog_type)) assert_success(response, None) session.title with pytest.raises(error.NoSuchAlertException): session.alert.dismiss()
def test_add_non_session_cookie(session, url): a_year_from_now = int( (datetime.utcnow() + timedelta(days=365) - datetime.utcfromtimestamp(0)).total_seconds()) new_cookie = { "name": "hello", "value": "world", "expiry": a_year_from_now } session.url = url("/common/blank.html") clear_all_cookies(session) result = add_cookie(session, new_cookie) assert_success(result) cookie = session.cookies("hello") assert "name" in cookie assert isinstance(cookie["name"], basestring) assert "value" in cookie assert isinstance(cookie["value"], basestring) assert "expiry" in cookie assert isinstance(cookie["expiry"], int) assert cookie["name"] == "hello" assert cookie["value"] == "world" assert cookie["expiry"] == a_year_from_now
def test_title_with_duplicate_element(session): session.url = inline("<title>First</title><title>Second</title>") result = session.transport.send("GET", "session/%s/title" % session.session_id) assert_success(result, read_global(session, "document.title"))
def test_add_domain_cookie(session, url, server_config): new_cookie = { "name": "hello", "value": "world", "domain": server_config["browser_host"], "path": "/", "httpOnly": False, "secure": False } session.url = url("/common/blank.html") clear_all_cookies(session) result = add_cookie(session, new_cookie) assert_success(result) cookie = session.cookies("hello") assert "domain" in cookie assert isinstance(cookie["domain"], basestring) assert "name" in cookie assert isinstance(cookie["name"], basestring) assert "value" in cookie assert isinstance(cookie["value"], basestring) assert cookie["name"] == "hello" assert cookie["value"] == "world" assert cookie["domain"] == server_config["browser_host"] or \ cookie["domain"] == ".%s" % server_config["browser_host"]
def test_add_session_cookie_with_leading_dot_character_in_domain(session, url, server_config): new_cookie = { "name": "hello", "value": "world", "domain": ".%s" % server_config["browser_host"] } session.url = url("/common/blank.html") clear_all_cookies(session) result = add_cookie(session, new_cookie) assert_success(result) cookie = session.cookies("hello") assert "name" in cookie assert isinstance(cookie["name"], basestring) assert "value" in cookie assert isinstance(cookie["value"], basestring) assert "domain" in cookie assert isinstance(cookie["domain"], basestring) assert cookie["name"] == "hello" assert cookie["value"] == "world" assert cookie["domain"] == server_config["browser_host"] or \ cookie["domain"] == ".%s" % server_config["browser_host"]
def test_add_cookie_for_ip(session, url, server_config, configuration): new_cookie = { "name": "hello", "value": "world", "domain": "127.0.0.1", "path": "/", "httpOnly": False, "secure": False } session.url = "http://127.0.0.1:%s/common/blank.html" % (server_config["ports"]["http"][0]) clear_all_cookies(session) result = add_cookie(session, new_cookie) assert_success(result) cookie = session.cookies("hello") assert "name" in cookie assert isinstance(cookie["name"], basestring) assert "value" in cookie assert isinstance(cookie["value"], basestring) assert "domain" in cookie assert isinstance(cookie["domain"], basestring) assert cookie["name"] == "hello" assert cookie["value"] == "world" assert cookie["domain"] == "127.0.0.1"
def test_abort_by_user_prompt(session, dialog_type): response = execute_async_script( session, "window.{}('Hello'); arguments[0](1);".format(dialog_type)) assert_success(response, None) session.alert.accept()
def test_resettable_element_does_not_satisfy_validation_constraints(session, type, invalid_value): """ Some UAs allow invalid input to certain types of constrained form controls. For example, Gecko allows non-valid characters to be typed into <input type=number> but Chrome does not. Since we want to test that Element Clear works for clearing the invalid characters in these UAs, it is fine to skip this test where UAs do not allow the element to not satisfy its constraints. """ session.url = inline("<input type=%s>" % type) element = session.find.css("input", all=False) def is_valid(element): return session.execute_script(""" var input = arguments[0]; return input.validity.valid; """, args=(element,)) # value property does not get updated if the input is invalid element.send_keys(invalid_value) # UA does not allow invalid input for this form control type if is_valid(element): return response = element_clear(session, element) assert_success(response) assert is_valid(element)
def test_scroll_into_view(session): session.url = inline(""" <input value=foobar> <div style='height: 200vh; width: 5000vh'> """) element = session.find.css("input", all=False) assert element.property("value") == "foobar" assert session.execute_script("return window.scrollY") == 0 # scroll to the bottom right of the page session.execute_script(""" let {scrollWidth, scrollHeight} = document.body; window.scrollTo(scrollWidth, scrollHeight); """) # clear and scroll back to the top of the page response = element_clear(session, element) assert_success(response) assert element.property("value") == "" # check if element cleared is scrolled into view rect = session.execute_script(""" let [input] = arguments; return input.getBoundingClientRect(); """, args=(element,)) window = session.execute_script(""" let {innerHeight, innerWidth, pageXOffset, pageYOffset} = window; return {innerHeight, innerWidth, pageXOffset, pageYOffset}; """) assert rect["top"] < (window["innerHeight"] + window["pageYOffset"]) and \ rect["left"] < (window["innerWidth"] + window["pageXOffset"]) and \ (rect["top"] + element.rect["height"]) > window["pageYOffset"] and \ (rect["left"] + element.rect["width"]) > window["pageXOffset"]
def test_not_blurred(session, tag): session.url = inline("<%s>" % tag) element = session.find.css(tag, all=False) response = element_send_keys(session, element, "") assert_success(response) assert_element_has_focus(element)
def test_get_default_timeouts(session): response = get_timeouts(session) assert_success(response) assert response.body["value"]["script"] == 30000 assert response.body["value"]["implicit"] == 0 assert response.body["value"]["pageLoad"] == 300000
def test_find_element_partial_link_text(session, document, value): # Step 8 - 9 session.url = inline("<div>{0}</div>".format(document)) element = session.find.css("div", all=False) response = find_element(session, element.id, "partial link text", value) assert_success(response)
def test_await_promise_resolve(session): response = execute_async_script(session, """ let resolve = arguments[0]; let res = await Promise.resolve('foobar'); resolve(res); """) assert_success(response, "foobar")
def test_find_elements(session, using, value): # Step 8 - 9 session.url = inline("<a href=# id=linkText>full link text</a>") response = find_elements(session, using, value) assert_success(response) assert len(response.body["value"]) == 1
def test_source_matches_outer_html(session): session.url = inline("<html><head><title>Cheese</title><body>Peas") expected = session.execute_script("return document.documentElement.outerHTML") response = get_page_source(session) assert_success(response, expected)
def test_negative_x_y(session): original = session.window.rect # step 13 response = set_window_rect(session, {"x": - 8, "y": - 8}) # step 14 os = session.capabilities["platformName"] # certain WMs prohibit windows from being moved off-screen if os == "linux": rect = assert_success(response) assert rect["x"] <= 0 assert rect["y"] <= 0 assert rect["width"] == original["width"] assert rect["height"] == original["height"] # On macOS, windows can only be moved off the screen on the # horizontal axis. The system menu bar also blocks windows from # being moved to (0,0). elif os == "darwin": assert_success(response, {"x": -8, "y": 23, "width": original["width"], "height": original["height"]}) # It turns out that Windows is the only platform on which the # window can be reliably positioned off-screen. elif os == "windows_nt": assert_success(response, {"x": -8, "y": -8, "width": original["width"], "height": original["height"]})
def test_maximize(session): before_size = session.window.size response = maximize(session) assert_success(response) assert before_size != session.window.size
def test_fully_exit_fullscreen(session): session.window.fullscreen() assert is_fullscreen(session) response = maximize(session) assert_success(response) assert not is_fullscreen(session)
def test_element_not_selected(session): # 13.1 step 5 session.url = option_doc element = session.find.css("#notSelected", all=False) result = is_element_selected(session, element.id) assert_success(result, False)
def test_checkbox_not_selected(session): # 13.1 step 5 session.url = check_doc element = session.find.css("#notChecked", all=False) result = is_element_selected(session, element.id) assert_success(result, False)
def test_payload(session): expected = session.execute_script("""return { x: window.screenX, y: window.screenY, width: window.outerWidth, height: window.outerHeight }""") response = get_window_rect(session) value = assert_success(response) assert isinstance(value, dict) assert value == expected
def test_success_document(session): session.url = inline(""" <body> <h1>Heading</h1> <input /> <input /> <input style="opacity: 0" /> <p>Another element</p> </body>""") response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element)
def check_user_prompt_closed_without_exception(dialog_type, retval): session.url = inline("<input type=text>") create_dialog(dialog_type, text=dialog_type) response = get_active_element(session) element = assert_success(response) assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval) assert_is_active_element(session, element)
def test_height_width(session): original = session.window.rect max = session.execute_script(""" return { width: window.screen.availWidth, height: window.screen.availHeight, }""") # step 12 response = set_window_rect(session, { "width": max["width"] - 100, "height": max["height"] - 100 }) # step 14 assert_success( response, { "x": original["x"], "y": original["y"], "width": max["width"] - 100, "height": max["height"] - 100 })
def test_fully_exit_fullscreen(session): """ 4. Fully exit fullscreen. [...] To fully exit fullscreen a document document, run these steps: 1. If document's fullscreen element is null, terminate these steps. 2. Unfullscreen elements whose fullscreen flag is set, within document's top layer, except for document's fullscreen element. 3. Exit fullscreen document. """ session.window.fullscreen() assert session.execute_script("return window.fullScreen") is True response = maximize(session) assert_success(response) assert session.execute_script("return window.fullScreen") is False
def test_node_list(session, inline): session.url = inline(""" <p>foo <p>bar """) ps = session.find.css("p") response = execute_script(session, "return document.querySelectorAll('p')") value = assert_success(response) assert isinstance(value, list) assert len(value) == 2 for expected, actual in zip(ps, value): assert_same_element(session, expected, actual)
def test_parent_htmldocument(session, inline): session.url = inline("") from_element = session.execute_script( """return document.querySelector("body")""") expected = session.execute_script("return document.documentElement") response = find_elements(session, from_element.id, "xpath", "..") value = assert_success(response) assert isinstance(value, list) assert len(value) == 1 found_element = value[0] assert_same_element(session, found_element, expected)
def test_success_explicit_focus(session): session.url = inline(""" <body> <h1>Heading</h1> <input /> <iframe></iframe> </body>""") session.execute_script("document.body.getElementsByTagName('h1')[0].focus()") response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element) session.execute_script("document.body.getElementsByTagName('input')[0].focus()") response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element) session.execute_script("document.body.getElementsByTagName('iframe')[0].focus()") response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element) session.execute_script("document.body.getElementsByTagName('iframe')[0].focus();") session.execute_script(""" var iframe = document.body.getElementsByTagName('iframe')[0]; if (iframe.remove) { iframe.remove(); } else { iframe.removeNode(true); }""") response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element) session.execute_script("document.body.appendChild(document.createElement('textarea'))") response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element)
def check_user_prompt_closed_without_exception(dialog_type, retval): session.url = inline("<div><p>bar</p><div>") outer_element = session.find.css("div", all=False) inner_element = session.find.css("p", all=False) create_dialog(dialog_type, text=dialog_type) response = find_element(session, outer_element.id, "css selector", "p") value = assert_success(response) assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval) assert_same_element(session, value, inner_element)
def test_success_iframe_content(session): session.url = inline("<body></body>") session.execute_script(""" let iframe = document.createElement('iframe'); document.body.appendChild(iframe); let input = iframe.contentDocument.createElement('input'); iframe.contentDocument.body.appendChild(input); input.focus(); """) response = get_active_element(session) element = assert_success(response) assert_is_active_element(session, element)
def test_negative_x_y(session): original = session.window.rect # step 13 response = set_window_rect(session, {"x": -8, "y": -8}) # step 14 os = session.capabilities["platformName"] # certain WMs prohibit windows from being moved off-screen if os == "linux": rect = assert_success(response) assert rect["x"] <= 0 assert rect["y"] <= 0 assert rect["width"] == original["width"] assert rect["height"] == original["height"] # On macOS, windows can only be moved off the screen on the # horizontal axis. The system menu bar also blocks windows from # being moved to (0,0). elif os == "darwin": assert_success( response, { "x": -8, "y": 23, "width": original["width"], "height": original["height"] }) # It turns out that Windows is the only platform on which the # window can be reliably positioned off-screen. elif os == "windows_nt": assert_success( response, { "x": -8, "y": -8, "width": original["width"], "height": original["height"] })
def test_link_hash(session): id = "anchor" session.url = inline(""" <a href="#{url}">aaaa</a> <p id={id} style="margin-top: 5000vh">scroll here</p> """.format(url=id, id=id)) old_url = session.url element = session.find.css("a", all=False) response = element_click(session, element) assert_success(response) new_url = session.url assert "{url}#{id}".format(url=old_url, id=id) == new_url element = session.find.css("p", all=False) assert session.execute_script(""" let [input] = arguments; rect = input.getBoundingClientRect(); return rect["top"] >= 0 && rect["left"] >= 0 && (rect["top"] + rect["height"]) <= window.innerHeight && (rect["left"] + rect["width"]) <= window.innerWidth; """, args=(element,)) is True
def check_user_prompt_not_closed_without_exception(dialog_type): session.url = inline("<input/>") element = session.find.css("input", all=False) create_dialog(dialog_type, text=dialog_type) response = take_element_screenshot(session, element.id) value = assert_success(response) image = base64.decodestring(value) assert imghdr.what("", image) == "png" assert session.alert.text == dialog_type session.alert.dismiss()
def check_user_prompt_closed_without_exception(dialog_type, retval): session.url = inline("<input/>") element = session.find.css("input", all=False) create_dialog(dialog_type, text=dialog_type) response = take_element_screenshot(session, element.id) value = assert_success(response) assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval) assert_png(value)
def test_html_document(session): session.url = inline("Test") response = do_print(session, { "page": { "width": 10, "height": 20 }, "shrinkToFit": False }) value = assert_success(response) pdf = base64.decodestring(ensure_binary(value)) # TODO: Test that the output is reasonable assert_pdf(pdf)
def test_find_element_partial_link_text(session, inline, get_shadow_page, document, value): # Step 8 - 9 session.url = inline(get_shadow_page("<div>{0}</div>".format(document))) custom_element = session.find.css("custom-shadow-element", all=False) expected = session.execute_script( "return arguments[0].shadowRoot.querySelectorAll('a')[0]", args=(custom_element, )) shadow_root = custom_element.shadow_root response = find_element(session, shadow_root.id, "partial link text", value) value = assert_success(response) assert_same_element(session, value, expected)
def test_pause_positive_integer(session, action_type): for valid_duration in [0, 1]: actions = [{ "type": action_type, "id": "foobar", "actions": [{ "type": "pause", "duration": valid_duration }] }] response = perform_actions(session, actions) assert_success(response) actions = [{ "type": action_type, "id": "foobar", "actions": [{ "type": "pause", "duration": -1 }] }] response = perform_actions(session, actions) assert_error(response, "invalid argument")
def test_platform_name(new_session, add_browser_capabilities, platform_name, body): capabilities = body("platformName", platform_name) if "alwaysMatch" in capabilities: capabilities["alwaysMatch"] = add_browser_capabilities( capabilities["alwaysMatch"]) else: capabilities["firstMatch"][0] = add_browser_capabilities( capabilities["firstMatch"][0]) response, _ = new_session({"capabilities": capabilities}) value = assert_success(response) assert value["capabilities"]["platformName"] == platform_name
def test_height_width_larger_than_max(session): max = session.execute_script(""" return { width: window.screen.availWidth, height: window.screen.availHeight, }""") response = set_window_rect(session, { "width": max["width"] + 100, "height": max["height"] + 100 }) rect = assert_success(response) assert rect["width"] >= max["width"] assert rect["height"] >= max["height"]
def test_fragments(session, url): test_pages = [ url("/common/blank.html"), url("/common/blank.html#1234"), url("/common/blank.html#5678"), ] for page in test_pages: session.url = page session.back() assert session.url == test_pages[1] session.back() assert session.url == test_pages[0] response = forward(session) assert_success(response) assert session.url == test_pages[1] response = forward(session) assert_success(response) assert session.url == test_pages[2]
def test_html_document(session, inline): session.url = inline("Test") response = do_print(session, { "page": { "width": 10, "height": 20 }, "shrinkToFit": False }) value = assert_success(response) pdf = decodebytes(value.encode()) # TODO: Test that the output is reasonable assert_pdf(pdf)
def test_add_non_session_cookie(session, url): a_day_from_now = int((datetime.utcnow() + timedelta(days=1) - datetime.utcfromtimestamp(0)).total_seconds()) new_cookie = {"name": "hello", "value": "world", "expiry": a_day_from_now} session.url = url("/common/blank.html") clear_all_cookies(session) result = add_cookie(session, new_cookie) assert_success(result) cookie = session.cookies("hello") assert "name" in cookie assert isinstance(cookie["name"], str) assert "value" in cookie assert isinstance(cookie["value"], str) assert "expiry" in cookie assert isinstance(cookie["expiry"], int) assert cookie["name"] == "hello" assert cookie["value"] == "world" assert cookie["expiry"] == a_day_from_now
def check_user_prompt_closed_without_exception(dialog_type, retval): session.url = checkbox_dom element = session.find.css("custom-checkbox-element", all=False) create_dialog(dialog_type, text=dialog_type) response = get_shadow_root(session, element.id) value = assert_success(response) assert isinstance(value, dict) assert "shadow-075b-4da1-b6ba-e579c2d3230a" in dict assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval)
def test_html_collection(session): session.url = inline(""" <p>foo <p>bar """) ps = session.find.css("p") response = execute_script(session, "return document.getElementsByTagName('p')") value = assert_success(response) assert isinstance(value, list) assert len(value) == 2 for expected, actual in zip(ps, value): assert_same_element(session, expected, actual)
def test_find_elements_partial_link_text(session, document, value): # Step 8 - 9 session.url = inline( "<div><a href=#>not wanted</a><br/>{0}</div>".format(document)) element = session.find.css("div", all=False) expected = session.execute_script("return document.links[1];") response = find_elements(session, element.id, "partial link text", value) value = assert_success(response) assert isinstance(value, list) assert len(value) == 1 found_element = value[0] assert_same_element(session, found_element, expected)
def check_user_prompt_closed_without_exception(dialog_type, retval): session.url = inline("<input/>") create_dialog(dialog_type, text=dialog_type) response = do_print(session, {}) value = assert_success(response) pdf = base64.decodestring(ensure_binary(value)) assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval) assert_pdf(pdf)
def test_maximize(session): """ 6. Maximize the window of the current browsing context. [...] To maximize the window, given an operating system level window with an associated top-level browsing context, run the implementation-specific steps to transition the operating system level window into the maximized window state. If the window manager supports window resizing but does not have a concept of window maximation, the window dimensions must be increased to the maximum available size permitted by the window manager for the current screen. Return when the window has completed the transition, or within an implementation-defined timeout. """ before_size = session.window.size response = maximize(session) assert_success(response) assert before_size != session.window.size
def test_iframe_is_interactable(session): session.url = inline( iframe(""" <body onkeypress="document.querySelector('input').value += event.key"> <input> </body> """)) body = session.find.css("body", all=False) frame = session.find.css("iframe", all=False) # By default the body has the focus assert session.active_element == body response = element_send_keys(session, frame, "foo") assert_success(response) assert session.active_element == frame # Any key events are immediately routed to the nested # browsing context's active document. session.switch_frame(frame) result = session.find.css("input", all=False) assert result.property("value") == "foo"
def check_user_prompt_closed_without_exception(dialog_type, retval): create_cookie("foo", value="bar", path="/common/blank.html") create_dialog(dialog_type, text=dialog_type) response = get_named_cookie(session, "foo") cookie = assert_success(response) assert_dialog_handled(session, expected_text=dialog_type, expected_retval=retval) assert cookie["name"] == "foo" assert cookie["value"] == "bar"
def test_source_origin(session, url, domain): # Create a reference element which looks exactly like the iframe session.url = inline("{0}{1}".format(REFERENCE_STYLE, REFERENCE_CONTENT)) div = session.find.css("div", all=False) div_dimensions = element_dimensions(session, div) response = take_element_screenshot(session, div.id) reference_screenshot = assert_success(response) assert png_dimensions(reference_screenshot) == div_dimensions iframe_content = "{0}{1}".format(INNER_IFRAME_STYLE, DEFAULT_CONTENT) session.url = inline("""{0}{1}""".format( OUTER_IFRAME_STYLE, iframe(iframe_content, domain=domain))) frame_element = session.find.css("iframe", all=False) frame_dimensions = element_dimensions(session, frame_element) response = take_element_screenshot(session, frame_element.id) screenshot = assert_success(response) assert png_dimensions(screenshot) == frame_dimensions assert screenshot == reference_screenshot