Sends a long press of keycode to the device. Android only. Possible keycodes can be found in http://developer.android.com/reference/android/view/KeyEvent.html. Args: keycode: the keycode to be sent to the device metastate: meta information about the
(self, keycode: int, metastate: Optional[int] = None, flags: Optional[int] = None)
| 112 | return self |
| 113 | |
| 114 | def long_press_keycode(self, keycode: int, metastate: Optional[int] = None, flags: Optional[int] = None) -> Self: |
| 115 | """Sends a long press of keycode to the device. |
| 116 | |
| 117 | Android only. Possible keycodes can be found in |
| 118 | http://developer.android.com/reference/android/view/KeyEvent.html. |
| 119 | |
| 120 | Args: |
| 121 | keycode: the keycode to be sent to the device |
| 122 | metastate: meta information about the keycode being sent |
| 123 | flags: the set of key event flags |
| 124 | |
| 125 | Returns: |
| 126 | Union['WebDriver', 'Keyboard']: Self instance |
| 127 | """ |
| 128 | ext_name = 'mobile: pressKey' |
| 129 | args = {'keycode': keycode} |
| 130 | if metastate is not None: |
| 131 | args['metastate'] = metastate |
| 132 | if flags is not None: |
| 133 | args['flags'] = flags |
| 134 | try: |
| 135 | self.assert_extension_exists(ext_name).execute_script( |
| 136 | ext_name, |
| 137 | { |
| 138 | **args, |
| 139 | 'isLongPress': True, |
| 140 | }, |
| 141 | ) |
| 142 | except UnknownMethodException: |
| 143 | # TODO: Remove the fallback |
| 144 | self.mark_extension_absence(ext_name).execute(Command.LONG_PRESS_KEYCODE, args) |
| 145 | return self |
| 146 | |
| 147 | def _add_commands(self) -> None: |
| 148 | self.command_executor.add_command( |