selenium
  1. selenium-webdriver-commands

WebDriver Commands - (Selenium WebDriver)

Webdriver Commands are the methods used to interact with the web elements on a web page. Selenium WebDriver provides a set of various commands and methods that can be used to automate web testing.

Syntax

driver.command(parameters)

Example

driver.get("https://www.example.com") #To open the webpage
driver.find_element_by_name('example').click() #To click the element with the name attribute value as example
driver.find_element_by_id("example").send_keys("hello") #To enter some text in the text-field with id as example

List of WebDriver Commands

Some of the commonly used webDriver Commands are:

Commands Description
get(url) Load a new web page in the current browser window. Accepts an absolute URL as a parameter.
find_element_by_id(id) Finds an element by its ID.
find_element_by_name(name) Finds an element by name.
find_element_by_xpath(xpath) Finds an element based on the XPATH expression.
find_element_by_link_text(link_text) Finds an anchor element by the text it displays.
find_element_by_partial_link_text(link_text) Finds an anchor element whose visible text contains the input string.
find_element_by_tag_name(tag_name) Finds an element by tag name.
find_element_by_class_name(class_name) Finds an element by class name.
find_element_by_css_selector(css_selector) For finding elements using CSS selectors.
send_keys(key) Sends the string keys to the active element.
click() Clicks the current element.
clear() Clears the text of the current element.
get_attribute(name) Returns the value of the specified attribute of the current element.
get_property(name) Returns the value of the specified property of the current element.
execute_script(script, *args) Executes a JavaScript script in the context of the currently selected frame or window.

Output

The WebDriver Commands perform the automation tasks on the web page and can print the output of the log.

Explanation

WebDriver is a web application testing tool that provides a simple and effective interface for automating and testing web applications. It allows us to control a browser through a program. Using WebDriver, we can interact with web elements like textbox, checkboxes, and dropdowns. WebDriver Commands are used to interact with these elements and automate the web testing process.

Use

WebDriver Commands are used for automating web testing. They help in performing various tasks like entering data in text fields, validating web elements, navigating between different web pages, etc. WebDriver Commands can be used for automated regression testing as well as for functional testing.

Important Points

  • WebDriver Commands are used to interact with web elements on a web page.
  • They can be used for automating web testing and various tasks like entering data in text fields, validating web elements, navigating between different web pages, etc.
  • WebDriver Commands can be used for automated regression testing as well as for functional testing.

Summary

WebDriver Commands are a set of methods used to interact with web elements on a web page. They are used for automating web testing and help in performing various tasks like entering data in text fields, validating web elements, navigating between different web pages, etc. WebDriver Commands can be used for automated regression testing as well as for functional testing. Some of the commonly used WebDriver Commands include find_element_by_id, find_element_by_xpath, send_keys, and click.

Published on: