Selenium WebDriver C# - get text

c#, c#-4.0, selenium, webdriver

Solution

You could easily get by using `class-name`:

driver.FindElement(By.Class("anketa_item-city")).Text;

or using `Xpath`

driver.FindElement(By.Xpath("\li\div")).Text;

Problem

I have this Html element on the page: ``` <li id="city" class="anketa_list-item"> <div class="anketa_item-city">From</div> London </li> ``` I found this element: ``` driver.FindElement(By.Id("city")) ``` If I try: `driver.FindElement(By.Id("city")).Text`, => my result: "From\r\nLondon". How can I get only London by WebDriver?

Original source