How can I get page title using Selenium C# Webdriver?
We can get the text from a website using Selenium webdriver USING the getText method. It helps to obtain the text for a particular element which is visible or the inner text (which is not concealed from the page).
Method to verify title We use getTitle() method to get the actual title of any web page. We store the title in the string and then we use Assert selenium command to return true or false. We can also use If-statement to compare actual and expected web page title.
New Selenium IDE An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value']. Let us take an html code for an element with a title attribute.
Or I think that
driver.Title;
also works?
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With