Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 870
user1838551 Avatar asked Nov 20 '12 11:11

user1838551


People also ask

How do I get page text in Selenium?

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).

How do you verify the title of a 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.

How do you get the element title in Selenium?

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.


2 Answers

Or I think that

driver.Title;

also works?

like image 112
DevDave Avatar answered Nov 10 '22 03:11

DevDave


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;
}
like image 40
PD Mohanty Avatar answered Nov 10 '22 05:11

PD Mohanty