user1838551
user1838551

Reputation: 69

How to get a page name using Selenium Webdriver (C#)?

How can I get page title using Selenium C# Webdriver?

Upvotes: 6

Views: 30511

Answers (3)

PD Mohanty
PD Mohanty

Reputation: 64

You can get the title of the page by using: -driver.Title;

Below i have written a small test that can help you understand how it works..

public void someTest()
{
 driver.Navigate().GoToUrl("http://google.com");
 String title=driver.Title;
}

Upvotes: 2

Robert L.
Robert L.

Reputation: 1529

driver.Title is the easy way to get the title of the page. It returns a string.

string myTitle = driver.Title;

If you want the title as an IWebElement then you can also get it by searching the DOM.

IWebElement myTitle = driver.FindElement(By.TagName("title"));

Upvotes: 2

DevDave
DevDave

Reputation: 6888

Or I think that

driver.Title;

also works?

Upvotes: 11

Related Questions