Reputation: 202
Hi i just would add string "value" in path
my code looke like :
string value = "Dodaj ofertę";
drive.FindElement(By.XPath("//*[@value='Dodaj ofertę']")).Click();
All i need to do is just
drive.FindElement(By.XPath("//*[@value='{value}']")).Click();
but this is incorrect. How can i do that? Please be patient for newbies.
Upvotes: 0
Views: 29
Reputation: 37299
To use the string interpolation feature you should add $
before the string:
drive.FindElement(By.XPath($"//*[@value='{value}']")).Click();
And if prior to C# 6.0 using string.Format
:
drive.FindElement(By.XPath(string.Format("//*[@value='{0}']", value))).Click();
Upvotes: 1