/// Get all window handles for the current session.
///
/// # Example:
/// ```rust
/// # use thirtyfour::prelude::*;
/// # use thirtyfour::support::block_on;
/// #
/// # fn main() -> WebDriverResult<()> {
/// #     block_on(async {
/// #         let caps = DesiredCapabilities::chrome();
/// #         let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps).await?;
/// #         driver.get("http://webappdemo").await?;
/// #         driver.find_element(By::Id("pagetextinput")).await?.click().await?;
/// #         assert_eq!(driver.title().await?, "Demo Web App");
/// assert_eq!(driver.window_handles().await?.len(), 1);
/// // Open a new tab.
/// driver.execute_script(r#"window.open("about:blank", target="_blank");"#).await?;
/// // Get window handles and switch to the new tab.
/// let handles = driver.window_handles().await?;
/// assert_eq!(handles.len(), 2);
/// driver.switch_to().window(&handles[1]).await?;
/// #         driver.quit().await?;
/// #         Ok(())
/// #     })
/// # }
/// ```
Get all window handles for the current session.
Get all window handles for the current session .
async fn window_handles(&self) -> WebDriverResult<Vec<WindowHandle>> {
        let v = self.cmd(Command::GetWindowHandles).await?;
        let strings: Vec<String> = convert_json_vec(&v["value"])?;
        Ok(strings.iter().map(WindowHandle::from).collect())
    }
async fn window_handles ( & self ) -> WebDriverResult < Vec < WindowHandle > > { let v = self . cmd ( Command :: GetWindowHandles ) . await ? ; let strings : Vec < String > = convert_json_vec ( & v [ " " ] ) ? ; Ok ( strings . iter ( ) . map ( WindowHandle :: from ) . collect ( ) ) }
Get all window handles for the current session.
Get all window handles for the current session .
&self
<not_specific>
example:
None
use thirtyfour::prelude::*;
None
use thirtyfour::support::block_on;
None
fn main() -> webdriverresult<()> {
None
block_on(async {
None
let caps = desiredcapabilities::chrome();
None
let driver = webdriver::new("http://localhost:4444/wd/hub", &caps).await?;
None
driver.get("http://webappdemo").await?;
None
driver.find_element(by::id("pagetextinput")).await?.click().await?;
None
assert_eq!(driver.title().await?, "demo web app");
assert_eq!(driver.window_handles().await?.len(), 1);
Open a new tab.
driver.execute_script(r#"window.open("about:blank", target="_blank");"#).await?;
Get window handles and switch to the new tab.
let handles = driver.window_handles().await?;
assert_eq!(handles.len(), 2);
driver.switch_to().window(&handles[1]).await?.
assert_eq! ( driver . window_handles () . await? . len () 1 ) ; Open a new tab . driver . execute_script ( r# " window . open ( " about : blank " target = " _blank " ) ; " # ) . await? ; Get window handles and switch to the new tab . let handles = driver . window_handles () . await? ; assert_eq! ( handles . len () 2 ) ; driver . switch_to () . window ( &handles [ 1 ] ) . await? .
driver.quit().await?;
None
ok(())
None
})
None
}
None