Reputation: 5745
I want to click on the Element
. I have following js code that does that trick:
$('#targetparam13 dd span.value')[2].click()
This is the code I am trying to get the same action using c# webdriver:
WDriver.FindElement(By.XPath("//*[@id=\"targetparam13\"]/dd/ul/li[3]/a/span")).Click();
How to achieve that?
Upvotes: 0
Views: 634
Reputation: 2795
python bindings but surely there should be a similar method for C# bindings:
driver.execute_script("$('#targetparam13 dd span.value')[2].click()")
Upvotes: 1
Reputation: 473783
You can use exactly the same CSS selector in By.CssSelector
locator:
WDriver.FindElements(By.CssSelector("#targetparam13 dd span.value"))[2].Click();
FindElements
method here would return us a list of "Web Elements", from which we can get the third element and click it.
Upvotes: 0