0

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?

2 Answers 2

1

python bindings but surely there should be a similar method for C# bindings:

driver.execute_script("$('#targetparam13 dd span.value')[2].click()")
Sign up to request clarification or add additional context in comments.

Comments

0

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.

2 Comments

Message = "Element is not currently visible and so may not be interacted with"
@sidux okay, this is a different problem now. There could be multiple reasons you've got the error..I think the best course of action here is to create a new question and add more details about the problem providing the url to the page under test or html of the page including the complete code you are currently executing and the stacktrace..thanks for understanding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.