A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/seleniumhq/selenium/commit/fd9d8d89325c76795402a0749e632601c138ebea below:

Simplify some `pointer_input` code · SeleniumHQ/selenium@fd9d8d8 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+23

-18

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+23

-18

lines changed Original file line number Diff line number Diff line change

@@ -14,15 +14,15 @@

14 14

# KIND, either express or implied. See the License for the

15 15

# specific language governing permissions and limitations

16 16

# under the License.

17 -

from .input_device import InputDevice

18 -

from .interaction import POINTER, POINTER_KINDS

17 +

import typing

19 18 20 19

from selenium.common.exceptions import InvalidArgumentException

21 20

from selenium.webdriver.remote.webelement import WebElement

21 +

from .input_device import InputDevice

22 +

from .interaction import POINTER, POINTER_KINDS

22 23 23 24 24 25

class PointerInput(InputDevice):

25 - 26 26

DEFAULT_MOVE_DURATION = 250

27 27 28 28

def __init__(self, kind, name):

@@ -34,20 +34,25 @@ def __init__(self, kind, name):

34 34

self.name = name

35 35 36 36

def create_pointer_move(self, duration=DEFAULT_MOVE_DURATION, x=0, y=0, origin=None, **kwargs):

37 -

action = dict(type="pointerMove", duration=duration)

38 -

action["x"] = x

39 -

action["y"] = y

40 -

action.update(**kwargs)

37 +

action = {

38 +

"type": "pointerMove",

39 +

"duration": duration,

40 +

"x": x,

41 +

"y": y,

42 +

**kwargs

43 +

}

41 44

if isinstance(origin, WebElement):

42 45

action["origin"] = {"element-6066-11e4-a52e-4f735466cecf": origin.id}

43 -

elif origin:

46 +

elif origin is not None:

44 47

action["origin"] = origin

45 - 46 48

self.add_action(self._convert_keys(action))

47 49 48 50

def create_pointer_down(self, **kwargs):

49 -

data = dict(type="pointerDown", duration=0)

50 -

data.update(**kwargs)

51 +

data = {

52 +

"type": "pointerDown",

53 +

"duration": 0,

54 +

**kwargs

55 +

}

51 56

self.add_action(self._convert_keys(data))

52 57 53 58

def create_pointer_up(self, button):

@@ -65,15 +70,15 @@ def encode(self):

65 70

"id": self.name,

66 71

"actions": self.actions}

67 72 68 -

def _convert_keys(self, actions):

73 +

def _convert_keys(self, actions: typing.Dict[str, typing.Any]):

69 74

out = {}

70 -

for k in actions.keys():

71 -

if actions[k] is None:

75 +

for k, v in actions.items():

76 +

if v is None:

72 77

continue

73 -

if k == "x" or k == "y":

74 -

out[k] = int(actions[k])

78 +

if k in ("x", "y"):

79 +

out[k] = int(v)

75 80

continue

76 81

splits = k.split('_')

77 82

new_key = splits[0] + ''.join(v.title() for v in splits[1:])

78 -

out[new_key] = actions[k]

83 +

out[new_key] = v

79 84

return out

Original file line number Diff line number Diff line change

@@ -320,7 +320,7 @@ def socks_version(self, value) -> None:

320 320

self.socksVersion = value

321 321 322 322

def _verify_proxy_type_compatibility(self, compatible_proxy):

323 -

if self.proxyType != ProxyType.UNSPECIFIED and self.proxyType != compatible_proxy:

323 +

if self.proxyType not in (ProxyType.UNSPECIFIED, compatible_proxy):

324 324

raise Exception(f"Specified proxy type ({compatible_proxy}) not compatible with current setting ({self.proxyType})")

325 325 326 326

def add_to_capabilities(self, capabilities):

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4