/// Create a new synchronous WebDriver struct.
///
/// # Example
/// ```ignore
/// use thirtyfour::sync::WebDriver;
/// use thirtyfour::DesiredCapabilities;
///
/// let caps = DesiredCapabilities::chrome();
/// let driver = WebDriver::new("http://localhost:4444/wd/hub", &caps)?;
/// ```
Create a new synchronous WebDriver struct.
Create a new synchronous WebDriver struct .
pub fn new(
        remote_server_addr: &str,
        capabilities: &DesiredCapabilities,
    ) -> WebDriverResult<Self> {
        let conn = Arc::new(RemoteConnectionSync::new(remote_server_addr)?);
        let v = conn.execute(Command::NewSession(capabilities))?;
        #[derive(Debug, Deserialize)]
        struct ConnectionData {
            #[serde(default, rename(deserialize = "sessionId"))]
            session_id: String,
            #[serde(default)]
            capabilities: serde_json::Value,
        }
        #[derive(Debug, Deserialize)]
        struct ConnectionResp {
            #[serde(default)]
            session_id: String,
            value: ConnectionData,
        }
        let resp: ConnectionResp = serde_json::from_value(v)?;
        let data = resp.value;
        let session_id = SessionId::from(if resp.session_id.is_empty() {
            data.session_id
        } else {
            resp.session_id
        });
        let actual_capabilities = data.capabilities;
        Ok(WebDriver {
            session_id,
            capabilities: actual_capabilities,
            conn,
        })
    }
pub fn new ( remote_server_addr : & str , capabilities : & DesiredCapabilities , ) -> WebDriverResult < Self > { let conn = Arc :: new ( RemoteConnectionSync :: new ( remote_server_addr ) ? ) ; let v = conn . execute ( Command :: NewSession ( capabilities ) ) ? ; # [ derive ( Debug Deserialize ) ] struct ConnectionData { # [ serde ( default rename ( deserialize " " ) ) ] session_id : String , # [ serde ( default ) ] capabilities : serde_json :: Value , } # [ derive ( Debug Deserialize ) ] struct ConnectionResp { # [ serde ( default ) ] session_id : String , value : ConnectionData , } let resp : ConnectionResp = serde_json :: from_value ( v ) ? ; let data = resp . value ; let session_id = SessionId :: from ( if resp . session_id . is_empty ( ) { data . session_id } else { resp . session_id } ) ; let actual_capabilities = data . capabilities ; Ok ( WebDriver { session_id , capabilities : actual_capabilities , conn , } ) }
Create a new synchronous WebDriver struct.
Create a new synchronous WebDriver struct .
remote_server_addr
&str
capabilities
&DesiredCapabilities
example
```ignore
use thirtyfour::sync::WebDriver;
use thirtyfour::DesiredCapabilities.


` ` ` ignore use thirtyfour :: sync :: WebDriver ; use thirtyfour :: DesiredCapabilities .