[−][src]Struct lw_webdriver::session::Session
This is the more important object. Tabs can be accessed within the session.
Example
use lw_webdriver::{session::Session, enums::Browser}; let mut session = Session::new(Browser::Firefox, false).unwrap(); // accessing default tab session.tabs[0].navigate("http://example.com/").unwrap(); // creating a new tab and access it session.open_tab().unwrap(); session.tabs[1].navigate("https://mubelotix.dev/").unwrap();
Fields
tabs: Vec<Tab>
Contains every manually created tabs and default tab. Do not contains tabs created by web pages with javascript unless you call update_tabs().
Methods
impl Session
[src]
pub fn new(browser: Browser, headless: bool) -> Result<Self, WebdriverError>
[src]
Create a session of a specific browser. Headless mean that the browser will be opened but not displayed (useful for servers). The crate will request a webdriver server at http://localhost:4444. If no webdriver is listening, one will be launched, but the program (geckodriver or chromedriver) must be located at the same place than the running program.
Example
let mut session = Session::new(Browser::Firefox, false).unwrap();
pub fn open_tab(&mut self) -> Result<usize, WebdriverError>
[src]
Create a new tab in the session. The tab will be directly accessible from the session (no call to update_tabs() needed).
Example
let mut session = Session::new(Browser::Firefox, false).unwrap(); assert_eq!(session.tabs.len(), 1); // default tab is already opened session.open_tab().unwrap(); assert_eq!(session.tabs.len(), 2); // new tab is accessible
pub fn update_tabs(&mut self) -> Result<(), WebdriverError>
[src]
When a tab is created with open_tab() method, it is accessible directly. But sometimes a tab is created by someone else (from a web page with javascript) and you don't want to care about it! This tab will not be accessible by your program because you never asked it. However if you want to access every open tab, call this function.
Example
let mut session = Session::new(Browser::Firefox, false).unwrap(); // only the default tab is open assert_eq!(session.tabs.len(), 1); // load a website session.tabs[0].navigate("https://mubelotix.dev/webdriver_tests/open_tab.html").unwrap(); // observe what is happening sleep(Duration::from_secs(5)); // a tab has been opened by another tab but you never asked for it // you can see two tabs displayed // but this crate don't show the useless one assert_eq!(session.tabs.len(), 1); // if you want to access it, call this function session.update_tabs().unwrap(); // now you can access two tabs! assert_eq!(session.tabs.len(), 2);
pub fn get_timeouts(&self) -> Result<Timeouts, WebdriverError>
[src]
This is a simple method getting timeouts of the session.
pub fn set_timeouts(&mut self, timeouts: Timeouts) -> Result<(), WebdriverError>
[src]
This is a simple method setting timeouts of the session.
Trait Implementations
impl Drop for Session
[src]
impl PartialEq<Session> for Session
[src]
impl WebdriverObject for Session
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Session
impl !Send for Session
impl !Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,