pub struct Keyboard<OT: ConnectionTransport> { /* private fields */ }Expand description
Keyboard input implementation for text entry and key presses.
Supports typing text, pressing special keys, and modifier key combinations. Key names follow WebDriver standard key codes (e.g., “Enter”, “Tab”, “ArrowLeft”).
§Examples
let keyboard = Keyboard::new(session);
// Type text
keyboard.type_text("Hello, World!", &context).await?;
// Press Enter
keyboard.press("Enter", &context).await?;
// Modifier keys
keyboard.down("Shift", &context).await?;
keyboard.press("a", &context).await?; // Types 'A'
keyboard.up("Shift", &context).await?;Implementations§
Source§impl<OT: ConnectionTransport> Keyboard<OT>
impl<OT: ConnectionTransport> Keyboard<OT>
Sourcepub async fn down(
&self,
key: &str,
context: &BrowsingContext,
) -> Result<(), InputError>
pub async fn down( &self, key: &str, context: &BrowsingContext, ) -> Result<(), InputError>
Presses a key down (without releasing).
Use with up to hold modifier keys or create custom key combinations.
Sourcepub async fn up(
&self,
key: &str,
context: &BrowsingContext,
) -> Result<(), InputError>
pub async fn up( &self, key: &str, context: &BrowsingContext, ) -> Result<(), InputError>
Releases a previously pressed key.
Sourcepub async fn press(
&self,
key: &str,
context: &BrowsingContext,
options: Option<KeyPressOptions>,
) -> Result<(), InputError>
pub async fn press( &self, key: &str, context: &BrowsingContext, options: Option<KeyPressOptions>, ) -> Result<(), InputError>
Presses and releases a key (keydown + keyup).
Accepts standard key names like “Enter”, “Tab”, “Escape”, “ArrowUp”, etc., as well as single characters.
Sourcepub async fn type_text(
&self,
text: &str,
context: &BrowsingContext,
options: Option<KeyboardTypeOptions>,
) -> Result<(), InputError>
pub async fn type_text( &self, text: &str, context: &BrowsingContext, options: Option<KeyboardTypeOptions>, ) -> Result<(), InputError>
Types a string of text character by character.
Each character is pressed and released in sequence. Use the delay option
to add pauses between characters for more human-like typing.
Auto Trait Implementations§
impl<OT> Freeze for Keyboard<OT>
impl<OT> !RefUnwindSafe for Keyboard<OT>
impl<OT> Send for Keyboard<OT>where
OT: Send,
impl<OT> Sync for Keyboard<OT>where
OT: Send,
impl<OT> Unpin for Keyboard<OT>
impl<OT> !UnwindSafe for Keyboard<OT>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more