Selenium Commands

List of Selenium Commands

Table of Contents

In Selenium, all those  commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.

There are three types of commands like:

Actions– These commands directly interacts with the page elements like click, type etc.

Accessors– Allows to store the values.

Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).

Selenium webdriver has a huge list of commands which are used for test automation which is performed by different operations.

They are:

1.Browser commands

2.Navigation commands

3. Webelements commands

1. BROWSER Commands:

a) Get command

This method opens a new webpage in existing browser. It accepts the parameter as string and returns void.

get(String arg0) : void 

For example the command to load a website will be written as

Driver.get(“www.google.com”)

Create a class browserFunctions in java and package and write the code to open the google webpage.

b) GetPageSource command:

Here the method returns the source code of present webpage loaded on the current browser this accepts no parameter and returns string value.

getPageSource(): String  
driver.getPageSource();  

           or

String PageSource = driver.getPageSource();  

c) GetCurrentURL command:

The job of this command is to fetch the string which represents the current URL of the current webpage. This command returns a string value.

getCurrentUrl(): String  

For example, this command can be written  as

driver.getCurrentUrl();

Or

String CurrentUrl = driver.getCurrentUrl();

d) Get title command:

This command fetches the title of the current webpage. This command accepts no parameter and returns a string.

getTitle(): String

For example this command can be written as

driver.getTitle();    

    OR     

String Title = driver.getTitle(); 

e) Close command

The command is used to terminate the current browser window by operating by the webdriver at the current time. This method returns void.

close(): void 

f) Quit command

This method terminates all the windows operating by the web driver. It closes the browser itself. This returns void.

quit(): void 

For example this can be written as

driver.quit(); 

2. NAVIGATION commands:

  1. Navigate To

This method loads the new page in the current browser window. It returns nothing and accepts a string parameter.

to(String arg0) : void

for example it can be written as

driver.navigate().to(“WWW.H2KINFOSYS.COM”).

b) Navigate Forward

This method does the operation of clicking the forward button of any browser.It will not accept any parameter and not returns any value.

forward() : void 

for example it is written as

driver.navigate().forward();  

c) Navigate Back command

   In this web driver this method simulates the browser’s back button action. It will not allow any parameter and it returns void.

Driver. Navigate ().back ();

For example    driver.navigate ().back();

d) Refresh command

This method works as to refresh the browser. It does not take any parameter and returns void.

driver.navigate().refresh();

For example  driver.navigate().refresh();

3) WEB ELEMENTS COMMANDS:

a) Clear command

This method is used to clear the value of text type element. It will not accept any parameter and returns void.

WebElement user = driver.findElement(By.id(“User”));

user.clear();

b) Sendkeys command

This method prints the characters or values passed in the argument into the associated web element object.it will accept a char sequence as a parameter and its return type is void.

element.sendKeys(“enter text”);

for example:

WebElement user = driver.findElement(By.id("User"));
user.sendKeys(“TechBeamers");

c) Click command

The method does the click action at the web element; it will not accept any parameter and its return type is void.

 element.click();

for example:

WebElement user = driver.findElement(By.id(“User"));
booleanis displayed = user.isDisplayed();

d) GetText command

This method will give you the inner text value of the element and get Text () method may return a blank if the text is hidden.

element.getText();

for example

WebElement link = driver.findElement(By.xpath("MyLink"));
String strlink = link.getText();

8 Responses

  1. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.
    There are three types of commands:
    . Actions– These commands directly interacts with the page elements like click, type etc.
    .Accessors– Allows to store the values.
    .Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).
    Selenium web driver has a huge list of commands which are used for test automation which is performed by different operations.

    They are:
    1.Browser commands
    2.Navigation commands
    3. Web elements commands

  2. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.
    There are three types of commands like:
    Actions– These commands directly interacts with the page elements like click, type etc.
    Accessors– Allows to store the values.
    Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).
    Selenium web driver has a huge list of commands which are used for test automation which is performed by different operations.
    They are:
    1.Browser commands
    2.Navigation commands
    3. Web elements commands

  3. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.
    There are three types of commands like:
    *Actions– These commands directly interacts with the page elements like click, type etc.
    *Accessors– Allows to store the values.
    *Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).
    Selenium webdriver has a huge list of commands which are used for test automation which is performed by different operations.
    They are:
    1.Browser commands
    2. Navigation commands
    3. Webelements commands

  4. List of Selenium commands:
    Commands are those which we perform some operations like open the window, get the browser or clear the text that have typed are controntrolled by some commands are called as Selenium commands.
    There are three types of selenium commands:
    1. Actions (These are directly use the web elements interfaces like click, type,etc.)
    2. Accessors (Store the values)
    3. Assertions: It asserts (If fails test stopped) and verifies (if fails, it results in logs of failure and execution wait for long time)

    List of Selenium commands:
    1. Browser commands (GetpageSource, GetTitle, GetCommand , Close , Quit)
    2. Navigation Commands (Navigate to , NavigateForward , NavigateBackward , Refresh)
    3. Web elements commands (Clear , Sendkeys , Click,GetText )

  5. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.

    There are three types of commands like:
    Actions– These commands directly interacts with the page elements like click, type etc.
    Accessors– Allows to store the values.
    Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).

    Selenium webdriver has a huge list of commands which are used for test automation which is performed by different operations which are listed below:

    1.Browser commands

    2.Navigation commands

    3. Webelements commands

    1. BROWSER Commands:
    a) Get command
    b) GetPageSource command:
    c) GetCurrentURL command:
    d) Get title command:
    e) Close command
    f) Quit command

    2. NAVIGATION commands:
    a) Navigate Forward
    b) Navigate Back command
    c) Refresh command

    3) WEB ELEMENTS COMMANDS:
    a) Clear command
    b) Sendkeys command
    c) Click command
    d) GetText command

  6. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.
    There are three types of commands:
    . Actions– These commands directly interacts with the page elements like click, type etc.
    .Accessors– Allows to store the values.
    .Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).
    Selenium web driver has a huge list of commands which are used for test automation which is performed by different operations.

    They are:
    1.Browser commands
    2.Navigation commands
    3. Web elements commands

  7. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands.

    There are three types of commands like:

    Actions– These commands directly interacts with the page elements like click, type etc.

    Accessors– Allows to store the values.

    Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution Wait For (waiting period).

    Selenium webdriver has a huge list of commands which are used for test automation which is performed by different operations.

    They are:

    1.Browser commands

    2.Navigation commands

    3. Webelements commands

  8. In Selenium, all those commands in which we perform certain operations like open a window, or we get a URL or we clear some text from the view are controlled by some commands these commands are called as selenium commands. There are three types of commands:
    Actions– These commands directly interact with the page elements like click, type, etc.
    Accessors– Allows storing the values.
    Assertions- It asserts (when this commands fails, test stopped), verifies (when this fails, result logs the failure and continues with execution ),Wait For (waiting period).

    Selenium web driver has a huge list of commands which are used for test automation which is performed by different operations. They are :
    1.Browser commands
    2.Navigation commands
    3. Webelements commands

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class