HomeSelenium C#

Selenium C Sharp – Retrieving the Title of the Page

Selenium C Sharp – Retrieving the Title of the Page

<<Previous Post                            << Complete Tutorial>>                              Next Post>>

In the previous articles, I have explained few basics commands in Selenium C# API.

In this article, I am going to practically demonstrate retrieving the title of the page using Selenium C# API command Title.

Let’s get started.

Selenium C Sharp – Retrieving the Title of the Page

In this article, I am going to practically demonstrate by providing the task first followed by solution.

Task: Open the http://omayo.blogspot.com URL in Chrome browser and retrieve the title of the page.

Selenium C# - Retrieve Title

Solution: Lets follow the below steps:

1) Launch Visual Studio and select an existing project which is already configured with Selenium and WebDriverManager as shown below:

Navigate URL - Launch Project

2) Write the below code explained in the previous posts for navigating to the http://omayo.blogspot.com URL in chrome browser in maximized mode as shown below:

Selenium C# - Basic

3) Now use the driver.Title to retrieve the title of the page  and hover the mouse to see the return type of Title command as shown below:

Selenium C# - Title Return Type

4) Observe that the return type of Title is String, hence create a variable for String Class and assign the value retrieved by Title to the variable as shown below:

String title = driver.Title;

Screenshot:

Selenium C# - String Title

5) Print the above retrieved and stored title in the variable as shown below:

 

6) Save and click on ‘Start’ button to execute the above code.

Observe that the Selenium C# Script will get executed and the title of the page will be retrieved and printed as shown below:

Selenium C# - Title Printed

 

Here concludes this article.

In the next article, I will choose another Selenium command for performing different operation on the web page.

Next Steps:

  • > To learn more about Selenium C#, continue to the next post (Click on Next Post Link Below)
  • > Check complete Selenium C# Tutorial Contents here (Click here)

Please leave your questions/comments/feedback below.

Happy Learning ?

About Me > Naveen Repala

Connect to me on Linked In (Click here)

On a mission to contribute to the Software Testing Community in all possible ways.

<<Previous Post                            << Complete Tutorial>>                              Next Post>>

Comments (0)

Leave a Reply

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

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp