Skip to content

Commit

Permalink
fix incorrect w3c action encoding in python client (#6014)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlipps authored and lmtierney committed Jun 25, 2018
1 parent 4446b8d commit 04f9698
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions py/selenium/webdriver/common/actions/action_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def add_key_input(self, name):
self._add_input(new_input)
return new_input

def add_pointer_input(self, type_, name):
new_input = PointerInput(type_, name)
def add_pointer_input(self, kind, name):
new_input = PointerInput(kind, name)
self._add_input(new_input)
return new_input

Expand Down
6 changes: 6 additions & 0 deletions py/selenium/webdriver/common/actions/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
NONE = "none"
SOURCE_TYPES = set([KEY, POINTER, NONE])

POINTER_MOUSE = "mouse"
POINTER_TOUCH = "touch"
POINTER_PEN = "pen"

POINTER_KINDS = set([POINTER_MOUSE, POINTER_TOUCH, POINTER_PEN])


class Interaction(object):

Expand Down
2 changes: 1 addition & 1 deletion py/selenium/webdriver/common/actions/pointer_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class PointerActions(Interaction):

def __init__(self, source=None):
if source is None:
source = PointerInput(interaction.POINTER, "mouse")
source = PointerInput(interaction.POINTER_MOUSE, "mouse")
self.source = source
super(PointerActions, self).__init__(source)

Expand Down
11 changes: 8 additions & 3 deletions py/selenium/webdriver/common/actions/pointer_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@
# specific language governing permissions and limitations
# under the License.
from .input_device import InputDevice
from .interaction import POINTER, POINTER_KINDS

from selenium.common.exceptions import InvalidArgumentException
from selenium.webdriver.remote.webelement import WebElement


class PointerInput(InputDevice):

DEFAULT_MOVE_DURATION = 250

def __init__(self, type_, name):
def __init__(self, kind, name):
super(PointerInput, self).__init__()
self.type = type_
if (kind not in POINTER_KINDS):
raise InvalidArgumentException("Invalid PointerInput kind '%s'" % kind)
self.type = POINTER
self.kind = kind
self.name = name

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

def encode(self):
return {"type": self.type,
"parameters": {"pointerType": self.name},
"parameters": {"pointerType": self.kind},
"id": self.name,
"actions": [acts for acts in self.actions]}

0 comments on commit 04f9698

Please sign in to comment.