In our previous tutorial, we discussed how to install selenium and how the selenium web driver works. In this tutorial, we are going to learn the most used selenium web driver commands. If we have created a web driver object then we can use many commands on the web driver object to perform different tasks.
Now first we will see how to create a web driver object:-
from selenium import webdriver
driver = webdriver.Chrome(path= "D:\Ashish\Desktop\chromedriver.exe")
We have created a selenium webdriver object, now we can perform different tasks on webdriver objects with the help of these commands. So let’s start to describe these commands:-
Webdriver Commands Description
Commands | Description |
---|---|
add_cookie | It is used to add a cookie to your current session |
back | Goes one step backward in the browser history |
close | used to close the current browser window which is currently in focus |
current_url | Gets the URL of the current page |
current_window_handle | current_window_handle method returns the handle of the current window |
create_web_element | Creates a web element with the specified element_id |
delete_all_cookies | It is used to delete all cookies in your browser history |
execute_async_script | Asynchronously Executes JavaScript in the current window |
execute_script | Synchronously Executes JavaScript in the current window |
forward | To go forward |
fullscreen_window | Invokes the window manager-specific ‘full-screen operation |
get_cookie | It is used to get a cookie with a specified name |
get_log | Gets the log for a given log type |
get_screenshot_as_file | Saves a screenshot of the current window to a PNG image file |
get_screenshot_as_png | Gets the screenshot of the current window as a binary data |
get_window_rect | Gets the x and y coordinates of the window as well as the height and width of the current window |
implicitly_wait | Sets a sticky timeout to implicitly wait for an element to be found |
maximize_window | To maximize the window |
minimize_window | To minimize the window |
page_source | Gets the source of the current page |
quit | It will close all the browsers windows which are currently opened and terminate the WebDriver session |
refresh | It will refresh the page or reload the page |
set_page_load_timeout | Set the amount of time to wait for a page load to complete before throwing an error |
set_window_position | Sets the x and y positions of the current window |
title | Returns the title of the current page |
We have listed only webdriver methods, in our coming tutorial, we will cover all the topics one by one so doesn’t worry about these concepts. So we have successfully covered all the selenium web driver methods that are mostly used while fetching data.
Now in the next article, we will discuss How to Fetch Single Data in Selenium Webdriver.