Interacting With WebDriver

On this page you'll learn about all of the different methods that the Simple Selenium WebDriver class has to offer

Introduction

The WebDriver class contains all of the Simple Selenium functionality wrapped into an easy-to-use class. On this page, you'll learn how to use the WebDriver class in your web-scraping & general automation projects.

List of All Simple Selenium WebDriver Functions

Unwrap Driver

You can get the unwrapped Selenium webdriver object with:

seleniumDriver=driver.driver #Returns unwrapped Selenium webdriver object

Close Driver

You can do a clean shutdown of the webdriver web browser with:

driver.close() #Closes the webdriver & web browser cleanly

Close Active Tab

Close just the active tab:

driver.close_active_tab() #Closes the current active tab or the entire web browser if only one tab is open

Visit a Web Page

Visiting a webpage:

driver.visit("https://google.com") #Visits google.com

#Default options:
referrer=False #Whether webdriver should use a referrer before visiting the target page
use_random_delay=True #Delay between visiting referrer website & target website (if referrer!=False)
min_delay=3.0 #Minimum delay between visiting referrer website & target website (if referrer!=False)
max_delay=3.5 #Maximum delay between visiting referrer website & target website (if referrer!=False)

driver.visit("https://domain.com",referrer="https://google.com") #Visits google.com before domain.com, which sets the referrer as google.com

Focus Document

Focuses the main document:

Focus IFrame

Focuses a target IFrame:

Focus Parent IFrame

Focuses the parent document/iframe:

Get Application Cache

Get application cache:

Get Browser Capabilities

Get browser capabilities:

Get Desired Browser Capabilities

Get desired browser capabilities:

Get Page Source

Get the current active page's source code:

Get Browser Name

Gets the browser name:

Get Timeouts

Gets driver timeouts:

Get File Detector

Gets file detector:

Get Virtual Auth ID

Gets virtual authenticator ID:

Get Window Handles

Gets active window handles:

Get Device Orientation

Gets device orientation:

Get Current Active Window Handle

Gets active window handle:

Get Web Page Title

Gets the title of the current active webpage:

Get Mobile Object

Gets the driver's mobile object:

Get Log Types

Gets log types:

Get Current URL

Gets the current active page URL:

Get Base64 Screenshot

Gets a base64 encoded string of screenshot img file:

Get PNG Screenshot

Gets a bytes encoded string of screenshot png file:

Save File Screenshot

Screenshots & saves as a file in target directory:

Adds a cookie dict to browser:

Add Credential

Adds authentication credentials:

Add Virtual Authenticator

Adds virtual authenticator:

Previous Page

Go back to previous page:

Delete All Cookies

Delete all browser cookies:

Delete browser cookie by name:

Delete Downloadable Files

Delete downloadable files:

Download File

Download file by file name & directory:

Execute Async Script

Executes JS async script:

Execute Script

Executes JS script:

Forward Page

Go forward a page:

Full-Screen Window

Turn browser into full-screen mode:

Get cookie by name:

Get All Cookies

Get all cookies from browser:

Get All Credentials

Get all credentials:

Get Downloadable Files

Get downloadable file:

Get Log By Type

Get log from storage by type:

Get Pinned Scripts

Get pinned scripts:

Get Window Position

Get window position:

Get Window Rect

Gets window rect:

Get Window Size

Gets window size:

Implicitly Wait

Wait for x seconds:

Maximize Window

Maximizes the browser window:

Minimize Window

Minimizes the browser window:

Pin Script

Pins a script:

Prints the page:

Refresh Page

Refreshes the webpage:

Remove All Credentials

Removes all credentials:

Remove Credential

Removes credential by ID:

Remove Virtual Authenticator

Removes virtual authenticator:

Set Page Load Time

Sets max page load time in seconds:

Set Script Load Time

Sets max script load time in seconds:

Set User Verified

Sets user verified:

Set Window Position

Sets window position in pixels:

Set Window Size

Sets window size:

Start Client

Starts client:

Start Session

Starts session:

Stop Client

Stops client:

Unpin Script By Key

Unpins script key:

Last updated