@@ -507,7 +507,7 @@ impl Page {
507507 /// immediately loaded when `click()` resolves. To wait until navigation is
508508 /// finished an additional `wait_for_navigation()` is required:
509509 ///
510- /// # Example
510+ /// # Examples
511511 ///
512512 /// Trigger a navigation and wait until the triggered navigation is finished
513513 ///
@@ -521,9 +521,28 @@ impl Page {
521521 /// # }
522522 /// ```
523523 ///
524- /// # Example
525524 ///
526- /// Perform custom click
525+ /// Use [`click_with()`] to perform a custom click:
526+ ///
527+ /// ```no_run
528+ /// # use chromiumoxide::page::Page;
529+ /// # use chromiumoxide::error::Result;
530+ /// # use chromiumoxide::layout::Point;
531+ /// # use chromiumoxide::types::ClickOptions;
532+ /// # async fn demo(page: Page, point: Point) -> Result<()> {
533+ /// let options = ClickOptions::builder()
534+ /// .click_count(2)
535+ /// .build();
536+ ///
537+ /// page.click_with(point, options).await?;
538+ /// # Ok(())
539+ /// # }
540+ /// ```
541+ ///
542+ /// ## Advanced
543+ ///
544+ /// For advanced use cases, the same behavior can be achieved manually by
545+ /// issuing `DispatchMouseEventParams` commands directly via the CDP API.
527546 ///
528547 /// ```no_run
529548 /// # use chromiumoxide::page::Page;
@@ -561,6 +580,46 @@ impl Page {
561580 Ok ( self )
562581 }
563582
583+ /// Performs a mouse click event at the point's location using the provided
584+ /// [`ClickOptions`].
585+ ///
586+ /// This behaves the same as [`click()`], but allows customizing click behavior
587+ /// such as click count or other click-related options.
588+ ///
589+ /// The point is scrolled into view first, then the corresponding
590+ /// `DispatchMouseEventParams` commands are issued according to the supplied
591+ /// options.
592+ ///
593+ /// Bear in mind that if `click_with()` triggers a navigation, the new page is
594+ /// not immediately loaded when this function resolves. To wait until navigation
595+ /// is finished, an additional [`wait_for_navigation()`] is required.
596+ ///
597+ /// # Example
598+ ///
599+ /// Perform a double click using [`ClickOptions`]
600+ ///
601+ /// ```no_run
602+ /// # use chromiumoxide::page::Page;
603+ /// # use chromiumoxide::error::Result;
604+ /// # use chromiumoxide::layout::Point;
605+ /// # use chromiumoxide::types::ClickOptions;
606+ /// # async fn demo(page: Page, point: Point) -> Result<()> {
607+ /// let options = ClickOptions::builder()
608+ /// .click_count(2)
609+ /// .build();
610+ ///
611+ /// page.click_with(point, options)
612+ /// .await?
613+ /// .wait_for_navigation()
614+ /// .await?;
615+ /// # Ok(())
616+ /// # }
617+ /// ```
618+ pub async fn click_with ( & self , point : Point , options : ClickOptions ) -> Result < & Self > {
619+ self . inner . click_with ( point, options) . await ?;
620+ Ok ( self )
621+ }
622+
564623 /// Dispatches a `mousemove` event and moves the mouse to the position of
565624 /// the `point` where `Point.x` is the horizontal position of the mouse and
566625 /// `Point.y` the vertical position of the mouse.
0 commit comments