Reputation: 69
How can I get page title using Selenium C# Webdriver?
Upvotes: 6
Views: 30511
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
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