I've gone through the Selenium Documentation for locating elements, but I can't seem to figure out how to find the element in my code.
Here is my code from my .cshtml:
<a onclick="alter('@key', '@value')" href="#edit" id="@key-display">@value</a>
I am trying to locate and click the @value at the end. Here is what it looks like when I inspect the value on Chrome:
<a onclick="alter('February 9, 2018', '1.00000')" href="#edit" id="February 9, 2018-display">1.00000 gallons</a>
I am able to locate the element by link text like this:
chromeDriver.FindElementByLinkText("1.00000 gallons").Click();
However, the link text will change constantly and I want to be able to locate it after it changes.
I have tried locating by several ways:
chromeDriver.FindElementByLinkText("@value").Click();
chromeDriver.FindElementByXPath("//a[@id='@key-display']").Click();
chromeDriver.FindElementById("@key-display").Click()