Commit e443dd64 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

[Webdriver] Close the window after the drag and drop pointer test

Right now the Action API cannot generate the drag and drop actions by
sending the mouse press, mouse move and mouse release, because  the drag
and drop events are generated from the OS level. Therefore, Webdriver
WPT test test_drag_and_drop_with_draggable_element will fail and the
dragged element is still been dragged, the rest of tests will fail
because all the following mouse actions would not work correctly. I add
a fixture_session function to open a new window for every test.

Bug: 850071
Change-Id: Iaa00e8980567cebc70046fd244ecdc1376bf785a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368713Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801898}
parent 4fde167d
import pytest
from webdriver.error import NoSuchWindowException
@pytest.fixture
def session_new_window(capabilities, session):
# Prevent unreleased dragged elements by running the test in a new window.
original_handle = session.window_handle
session.window_handle = session.new_window()
yield session
try:
session.window.close()
except NoSuchWindowException:
pass
session.window_handle = original_handle
@pytest.fixture
def key_chain(session):
......
......@@ -144,12 +144,13 @@ def test_drag_and_drop(session,
@pytest.mark.parametrize("drag_duration", [0, 300, 800])
def test_drag_and_drop_with_draggable_element(session,
def test_drag_and_drop_with_draggable_element(session_new_window,
test_actions_page,
mouse_chain,
drag_duration):
drag_target = session.find.css("#draggable", all=False)
drop_target = session.find.css("#droppable", all=False)
new_session = session_with_new_window
drag_target = new_session.find.css("#draggable", all=False)
drop_target = new_session.find.css("#droppable", all=False)
# Conclude chain with extra move to allow time for last queued
# coordinate-update of drag_target and to test that drag_target is "dropped".
mouse_chain \
......@@ -163,7 +164,8 @@ def test_drag_and_drop_with_draggable_element(session,
.pointer_move(80, 50, duration=100, origin="pointer") \
.perform()
# mouseup that ends the drag is at the expected destination
e = get_events(session)
e = get_events(new_session)
assert len(e) >= 5
assert e[1]["type"] == "dragstart", "Events captured were {}".format(e)
assert e[2]["type"] == "dragover", "Events captured were {}".format(e)
drag_events_captured = [ev["type"] for ev in e if ev["type"].startswith("drag") or ev["type"].startswith("drop")]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment