Skip to content

Commit d706400

Browse files
fixed error
1 parent 82a4897 commit d706400

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

py/selenium/webdriver/common/actions/key_actions.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
from __future__ import annotations
1819

1920
from ..utils import keys_to_typing
@@ -27,7 +28,7 @@ class KeyActions(Interaction):
2728
def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -> None:
2829
if source is None:
2930
source = KeyInput(KEY)
30-
self.input_source = source
31+
self.input_source = source # Store the actual input object
3132

3233
# Determine the correct source type string based on the input object
3334
if isinstance(source, KeyInput):
@@ -38,18 +39,17 @@ def __init__(self, source: KeyInput | PointerInput | WheelInput | None = None) -
3839
source_type = WHEEL
3940
else:
4041
source_type = KEY # fallback
41-
42-
super().__init__(source_type)
43-
42+
43+
super().__init__(source_type) # Pass string to parent
4444

4545
def key_down(self, letter: str) -> KeyActions:
46-
return self.keyaction("create_key_down", letter)
46+
return self._key_action("create_key_down", letter)
4747

4848
def key_up(self, letter: str) -> KeyActions:
49-
return self.keyaction("create_key_up", letter)
49+
return self._key_action("create_key_up", letter)
5050

5151
def pause(self, duration: int = 0) -> KeyActions:
52-
return self.keyaction("create_pause", duration)
52+
return self._key_action("create_pause", duration)
5353

5454
def send_keys(self, text: str | list) -> KeyActions:
5555
if not isinstance(text, list):
@@ -59,7 +59,7 @@ def send_keys(self, text: str | list) -> KeyActions:
5959
self.key_up(letter)
6060
return self
6161

62-
def keyaction(self, action: str, letter) -> KeyActions:
63-
meth = getattr(self.input_source, action)
62+
def _key_action(self, action: str, letter) -> KeyActions:
63+
meth = getattr(self.input_source, action) # Use input_source, not source
6464
meth(letter)
6565
return self

0 commit comments

Comments
 (0)