pub struct GenericWebDriver<T: WebDriverHttpClientSync> {
pub session: WebDriverSession,
/* private fields */
}Expand description
NOTE: For WebDriver method documentation, see the WebDriverCommands trait.
The thirtyfour crate uses a generic struct that implements the
WebDriverCommands trait. The generic struct is then implemented for
a specific HTTP client.
This GenericWebDriver struct encapsulates a synchronous Selenium WebDriver browser
session. For the async driver, see GenericWebDriver.
§Example:
use thirtyfour_sync::prelude::*;
fn main() -> WebDriverResult<()> {
let caps = DesiredCapabilities::chrome();
let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps)?;
driver.get("http://webappdemo")?;
driver.quit()?;
Ok(())
}Fields§
§session: WebDriverSessionImplementations§
Source§impl<T> GenericWebDriver<T>where
T: WebDriverHttpClientSync + 'static,
impl<T> GenericWebDriver<T>where
T: WebDriverHttpClientSync + 'static,
Sourcepub fn new<C>(server_url: &str, capabilities: C) -> WebDriverResult<Self>where
C: Serialize,
pub fn new<C>(server_url: &str, capabilities: C) -> WebDriverResult<Self>where
C: Serialize,
The GenericWebDriver struct is not intended to be created directly.
Instead you would use the WebDriver struct, which wires up the GenericWebDriver with a HTTP client for making requests to the WebDriver server.
Create a new WebDriver as follows:
§Example
let caps = DesiredCapabilities::chrome();
let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps)?;NOTE: If the webdriver appears to hang or give no response, please check that the capabilities object is of the correct type for that webdriver.
Sourcepub fn new_with_timeout<C>(
server_url: &str,
capabilities: C,
timeout: Option<Duration>,
) -> WebDriverResult<Self>where
C: Serialize,
pub fn new_with_timeout<C>(
server_url: &str,
capabilities: C,
timeout: Option<Duration>,
) -> WebDriverResult<Self>where
C: Serialize,
Creates a new GenericWebDriver just like the new function. Allows a
configurable timeout for all HTTP requests including the session creation.
Create a new WebDriver as follows:
§Example
let caps = DesiredCapabilities::chrome();
let driver = WebDriver::new_with_timeout("http://localhost:4444/wd/hub", &caps, Some(Duration::from_secs(120)))?;Sourcepub fn capabilities(&self) -> DesiredCapabilities
pub fn capabilities(&self) -> DesiredCapabilities
Return a clone of the capabilities as returned by Selenium.
pub fn session_id(&self) -> &SessionId
pub fn config(&self) -> &WebDriverConfig
pub fn config_mut(&mut self) -> &mut WebDriverConfig
Sourcepub fn quit(self) -> WebDriverResult<()>
pub fn quit(self) -> WebDriverResult<()>
End the webdriver session.
Sourcepub fn set_request_timeout(&mut self, timeout: Duration) -> WebDriverResult<()>
pub fn set_request_timeout(&mut self, timeout: Duration) -> WebDriverResult<()>
Set the request timeout for the HTTP client.
§Example
let caps = DesiredCapabilities::chrome();
let mut driver = WebDriver::new("http://localhost:4444/wd/hub", &caps)?;
driver.set_request_timeout(Duration::from_secs(180))?;Source§impl<T> GenericWebDriver<T>where
T: WebDriverHttpClientSync + 'static,
impl<T> GenericWebDriver<T>where
T: WebDriverHttpClientSync + 'static,
pub fn set_query_poller(&mut self, poller: ElementPoller)
Trait Implementations§
Source§impl<T: Debug + WebDriverHttpClientSync> Debug for GenericWebDriver<T>
impl<T: Debug + WebDriverHttpClientSync> Debug for GenericWebDriver<T>
Source§impl<T> Drop for GenericWebDriver<T>where
T: WebDriverHttpClientSync,
impl<T> Drop for GenericWebDriver<T>where
T: WebDriverHttpClientSync,
Source§impl<T> WebDriverCommands for GenericWebDriver<T>where
T: WebDriverHttpClientSync,
impl<T> WebDriverCommands for GenericWebDriver<T>where
T: WebDriverHttpClientSync,
Source§fn session(&self) -> &WebDriverSession
fn session(&self) -> &WebDriverSession
Source§fn cmd(&self, command: Command) -> WebDriverResult<Value>
fn cmd(&self, command: Command) -> WebDriverResult<Value>
Source§fn get<S: Into<String>>(&self, url: S) -> WebDriverResult<()>
fn get<S: Into<String>>(&self, url: S) -> WebDriverResult<()>
Source§fn current_url(&self) -> WebDriverResult<String>
fn current_url(&self) -> WebDriverResult<String>
Source§fn page_source(&self) -> WebDriverResult<String>
fn page_source(&self) -> WebDriverResult<String>
Source§fn find_element(&self, by: By<'_>) -> WebDriverResult<WebElement<'_>>
fn find_element(&self, by: By<'_>) -> WebDriverResult<WebElement<'_>>
Source§fn find_elements(&self, by: By<'_>) -> WebDriverResult<Vec<WebElement<'_>>>
fn find_elements(&self, by: By<'_>) -> WebDriverResult<Vec<WebElement<'_>>>
Source§fn execute_script(&self, script: &str) -> WebDriverResult<ScriptRetSync<'_>>
fn execute_script(&self, script: &str) -> WebDriverResult<ScriptRetSync<'_>>
Source§fn execute_script_with_args(
&self,
script: &str,
args: &ScriptArgs,
) -> WebDriverResult<ScriptRetSync<'_>>
fn execute_script_with_args( &self, script: &str, args: &ScriptArgs, ) -> WebDriverResult<ScriptRetSync<'_>>
Source§fn execute_async_script(
&self,
script: &str,
) -> WebDriverResult<ScriptRetSync<'_>>
fn execute_async_script( &self, script: &str, ) -> WebDriverResult<ScriptRetSync<'_>>
Source§fn execute_async_script_with_args(
&self,
script: &str,
args: &ScriptArgs,
) -> WebDriverResult<ScriptRetSync<'_>>
fn execute_async_script_with_args( &self, script: &str, args: &ScriptArgs, ) -> WebDriverResult<ScriptRetSync<'_>>
Source§fn current_window_handle(&self) -> WebDriverResult<WindowHandle>
fn current_window_handle(&self) -> WebDriverResult<WindowHandle>
Source§fn window_handles(&self) -> WebDriverResult<Vec<WindowHandle>>
fn window_handles(&self) -> WebDriverResult<Vec<WindowHandle>>
Source§fn maximize_window(&self) -> WebDriverResult<()>
fn maximize_window(&self) -> WebDriverResult<()>
Source§fn minimize_window(&self) -> WebDriverResult<()>
fn minimize_window(&self) -> WebDriverResult<()>
Source§fn fullscreen_window(&self) -> WebDriverResult<()>
fn fullscreen_window(&self) -> WebDriverResult<()>
Source§fn get_window_rect(&self) -> WebDriverResult<Rect>
fn get_window_rect(&self) -> WebDriverResult<Rect>
Source§fn set_window_rect(&self, rect: OptionRect) -> WebDriverResult<()>
fn set_window_rect(&self, rect: OptionRect) -> WebDriverResult<()>
Source§fn back(&self) -> WebDriverResult<()>
fn back(&self) -> WebDriverResult<()>
Source§fn forward(&self) -> WebDriverResult<()>
fn forward(&self) -> WebDriverResult<()>
Source§fn get_timeouts(&self) -> WebDriverResult<TimeoutConfiguration>
fn get_timeouts(&self) -> WebDriverResult<TimeoutConfiguration>
Source§fn set_timeouts(&self, timeouts: TimeoutConfiguration) -> WebDriverResult<()>
fn set_timeouts(&self, timeouts: TimeoutConfiguration) -> WebDriverResult<()>
Source§fn set_implicit_wait_timeout(
&self,
time_to_wait: Duration,
) -> WebDriverResult<()>
fn set_implicit_wait_timeout( &self, time_to_wait: Duration, ) -> WebDriverResult<()>
Source§fn set_script_timeout(&self, time_to_wait: Duration) -> WebDriverResult<()>
fn set_script_timeout(&self, time_to_wait: Duration) -> WebDriverResult<()>
Source§fn set_page_load_timeout(&self, time_to_wait: Duration) -> WebDriverResult<()>
fn set_page_load_timeout(&self, time_to_wait: Duration) -> WebDriverResult<()>
Source§fn action_chain(&self) -> ActionChain<'_>
fn action_chain(&self) -> ActionChain<'_>
Source§fn screenshot_as_base64(&self) -> WebDriverResult<String>
fn screenshot_as_base64(&self) -> WebDriverResult<String>
Source§fn screenshot_as_png(&self) -> WebDriverResult<Vec<u8>>
fn screenshot_as_png(&self) -> WebDriverResult<Vec<u8>>
Source§fn screenshot(&self, path: &Path) -> WebDriverResult<()>
fn screenshot(&self, path: &Path) -> WebDriverResult<()>
Source§fn switch_to(&self) -> SwitchTo<'_>
fn switch_to(&self) -> SwitchTo<'_>
Source§fn set_window_name(&self, window_name: &str) -> WebDriverResult<()>
fn set_window_name(&self, window_name: &str) -> WebDriverResult<()>
driver.switch_to().window_name(name). Read more