Menu Close

Selenium Webdriver Commands | Most Used Selenium Webdriver Commands | Selenium Tutorial By DevDuniya- DevDuniya

WEB DRIVER COMMANDS

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

CommandsDescription
add_cookieIt is used to add a cookie to your current session
backGoes one step backward in the browser history
closeused to close the current browser window which is currently in focus
current_urlGets the URL of the current page
current_window_handlecurrent_window_handle method returns the handle of the current window
create_web_elementCreates a web element with the specified element_id
delete_all_cookiesIt is used to delete all cookies in your browser history
execute_async_scriptAsynchronously Executes JavaScript in the current window
execute_scriptSynchronously Executes JavaScript in the current window
forwardTo go forward
fullscreen_windowInvokes the window manager-specific ‘full-screen operation
get_cookieIt is used to get a cookie with a specified name
get_logGets the log for a given log type
get_screenshot_as_fileSaves a screenshot of the current window to a PNG image file
get_screenshot_as_pngGets the screenshot of the current window as a binary data
get_window_rectGets the x and y coordinates of the window as well as the height and width of the current window
implicitly_waitSets a sticky timeout to implicitly wait for an element to be found
maximize_windowTo maximize the window
minimize_windowTo minimize the window
page_sourceGets the source of the current page
quitIt will close all the browsers windows which are currently opened and terminate the WebDriver session
refreshIt will refresh the page or reload the page
set_page_load_timeoutSet the amount of time to wait for a page load to complete before throwing an error
set_window_positionSets the x and y positions of the current window
titleReturns the title of the current page
Web Driver Commands

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.

Suggested Blog Posts

Leave a Reply

Your email address will not be published.