Turgut Kanceltik
Turgut Kanceltik

Reputation: 639

Selecting an element with xpath and Selenium use contains

i need href website link. But is not. How can I invoke

My html code is this...

 <a href="https://www.google.com/blabla/blabla/blabla/blablabla" target="_blank">Çekme İşlemini Onayla</a>

My C# code is this...

var link = _driver.FindElement(By.XPath("//*/a[contains(.,'Çekme İşlemini Onayla')]")).Text;

help pls thank you..

Upvotes: 2

Views: 2577

Answers (2)

Madhu
Madhu

Reputation: 497

You can get by

string strhref =  driver.FindElement(By.XPath("//a[contains(.,'Çekme İşlemini Onayla')]")).GetAttribute("href");;

Upvotes: 0

har07
har07

Reputation: 89295

Instead of Text property, you can use GetAttribute() method to get an attribute value :

var a = _driver.FindElement(By.XPath("//a[contains(.,'Çekme İşlemini Onayla')]"));
var href = a.GetAttribute("href");

Upvotes: 1

Related Questions