Skip to content

Commit 04f9698

Browse files
jlippslmtierney
authored andcommitted
fix incorrect w3c action encoding in python client (#6014)
1 parent 4446b8d commit 04f9698

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

py/selenium/webdriver/common/actions/action_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def add_key_input(self, name):
6262
self._add_input(new_input)
6363
return new_input
6464

65-
def add_pointer_input(self, type_, name):
66-
new_input = PointerInput(type_, name)
65+
def add_pointer_input(self, kind, name):
66+
new_input = PointerInput(kind, name)
6767
self._add_input(new_input)
6868
return new_input
6969

py/selenium/webdriver/common/actions/interaction.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121
NONE = "none"
2222
SOURCE_TYPES = set([KEY, POINTER, NONE])
2323

24+
POINTER_MOUSE = "mouse"
25+
POINTER_TOUCH = "touch"
26+
POINTER_PEN = "pen"
27+
28+
POINTER_KINDS = set([POINTER_MOUSE, POINTER_TOUCH, POINTER_PEN])
29+
2430

2531
class Interaction(object):
2632

py/selenium/webdriver/common/actions/pointer_actions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class PointerActions(Interaction):
2727

2828
def __init__(self, source=None):
2929
if source is None:
30-
source = PointerInput(interaction.POINTER, "mouse")
30+
source = PointerInput(interaction.POINTER_MOUSE, "mouse")
3131
self.source = source
3232
super(PointerActions, self).__init__(source)
3333

py/selenium/webdriver/common/actions/pointer_input.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
from .input_device import InputDevice
18+
from .interaction import POINTER, POINTER_KINDS
1819

20+
from selenium.common.exceptions import InvalidArgumentException
1921
from selenium.webdriver.remote.webelement import WebElement
2022

2123

2224
class PointerInput(InputDevice):
2325

2426
DEFAULT_MOVE_DURATION = 250
2527

26-
def __init__(self, type_, name):
28+
def __init__(self, kind, name):
2729
super(PointerInput, self).__init__()
28-
self.type = type_
30+
if (kind not in POINTER_KINDS):
31+
raise InvalidArgumentException("Invalid PointerInput kind '%s'" % kind)
32+
self.type = POINTER
33+
self.kind = kind
2934
self.name = name
3035

3136
def create_pointer_move(self, duration=DEFAULT_MOVE_DURATION, x=None, y=None, origin=None):
@@ -53,6 +58,6 @@ def create_pause(self, pause_duration):
5358

5459
def encode(self):
5560
return {"type": self.type,
56-
"parameters": {"pointerType": self.name},
61+
"parameters": {"pointerType": self.kind},
5762
"id": self.name,
5863
"actions": [acts for acts in self.actions]}

0 commit comments

Comments
 (0)