зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1486793 - [wdspec] Add basic tests for "Take Element Screenshot" command. r=ato
--HG-- extra : rebase_source : 72490b5de3d88e451d33b1304f9d29bb826fceed
This commit is contained in:
Родитель
72e69dc39b
Коммит
812d9b4dbf
|
@ -311079,6 +311079,11 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/take_element_screenshot/__init__.py": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/take_screenshot/__init__.py": [
|
||||
[
|
||||
{}
|
||||
|
@ -424237,6 +424242,20 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/take_element_screenshot/screenshot.py": [
|
||||
[
|
||||
"/webdriver/tests/take_element_screenshot/screenshot.py",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/take_element_screenshot/user_prompts.py": [
|
||||
[
|
||||
"/webdriver/tests/take_element_screenshot/user_prompts.py",
|
||||
{
|
||||
"timeout": "long"
|
||||
}
|
||||
]
|
||||
],
|
||||
"webdriver/tests/take_screenshot/screenshot.py": [
|
||||
[
|
||||
"/webdriver/tests/take_screenshot/screenshot.py",
|
||||
|
@ -650070,6 +650089,18 @@
|
|||
"907be66a149e8196c87760544140636d9625bbb9",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/take_element_screenshot/__init__.py": [
|
||||
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
|
||||
"support"
|
||||
],
|
||||
"webdriver/tests/take_element_screenshot/screenshot.py": [
|
||||
"e4d2869af4f3a50aa4da87b499d84b75254967a7",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/take_element_screenshot/user_prompts.py": [
|
||||
"fa239999e4f3479526423498f5718a455ffde53f",
|
||||
"wdspec"
|
||||
],
|
||||
"webdriver/tests/take_screenshot/__init__.py": [
|
||||
"e69de29bb2d1d6434b8b29ae775ad8c2e48c5391",
|
||||
"support"
|
||||
|
|
|
@ -0,0 +1,40 @@
|
|||
import base64
|
||||
import imghdr
|
||||
|
||||
from tests.support.asserts import assert_error, assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
def take_element_screenshot(session, element_id):
|
||||
return session.transport.send(
|
||||
"GET",
|
||||
"session/{session_id}/element/{element_id}/screenshot".format(
|
||||
session_id=session.session_id,
|
||||
element_id=element_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def test_no_browsing_context(session, closed_window):
|
||||
response = take_element_screenshot(session, "foo")
|
||||
assert_error(response, "no such window")
|
||||
|
||||
|
||||
def test_screenshot(session):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
|
||||
response = take_element_screenshot(session, element.id)
|
||||
value = assert_success(response)
|
||||
|
||||
image = base64.decodestring(value)
|
||||
assert imghdr.what("", image) == "png"
|
||||
|
||||
|
||||
def test_stale(session):
|
||||
session.url = inline("<input>")
|
||||
element = session.find.css("input", all=False)
|
||||
session.refresh()
|
||||
|
||||
result = take_element_screenshot(session, element.id)
|
||||
assert_error(result, "stale element reference")
|
|
@ -0,0 +1,74 @@
|
|||
# META: timeout=long
|
||||
|
||||
import base64
|
||||
import imghdr
|
||||
|
||||
import pytest
|
||||
|
||||
from tests.support.asserts import assert_success
|
||||
from tests.support.inline import inline
|
||||
|
||||
|
||||
def take_element_screenshot(session, element_id):
|
||||
return session.transport.send(
|
||||
"GET",
|
||||
"session/{session_id}/element/{element_id}/screenshot".format(
|
||||
session_id=session.session_id,
|
||||
element_id=element_id,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def check_user_prompt_not_closed_without_exception(session, create_dialog):
|
||||
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()
|
||||
|
||||
return check_user_prompt_not_closed_without_exception
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_accept(check_user_prompt_not_closed_without_exception, dialog_type):
|
||||
check_user_prompt_not_closed_without_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "accept and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_accept_and_notify(check_user_prompt_not_closed_without_exception, dialog_type):
|
||||
check_user_prompt_not_closed_without_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_dismiss(check_user_prompt_not_closed_without_exception, dialog_type):
|
||||
check_user_prompt_not_closed_without_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "dismiss and notify"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_dismiss_and_notify(check_user_prompt_not_closed_without_exception, dialog_type):
|
||||
check_user_prompt_not_closed_without_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.capabilities({"unhandledPromptBehavior": "ignore"})
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_ignore(check_user_prompt_not_closed_without_exception, dialog_type):
|
||||
check_user_prompt_not_closed_without_exception(dialog_type)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("dialog_type", ["alert", "confirm", "prompt"])
|
||||
def test_default(check_user_prompt_not_closed_without_exception, dialog_type):
|
||||
check_user_prompt_not_closed_without_exception(dialog_type)
|
Загрузка…
Ссылка в новой задаче