I have been trying in selenium to click span element which has class named bullet. It's a tree structure where it expands it's children once clicked. I have tried in the following way, but it's not working. Below is the UI Code
<ul id="treelist" class="ltree">
<li class="liClosed">
<span class="bullet"> </span>
<b>Setup</b>
<ul>
<li></li>
<li></li>............
.....................
</ul>
</li>
</ul>
The error is: The given selector //*ul[@id='treelist']//li[2]//span is either invalid or does not result in a WebElement
The code I am using is:
WebDriver driver = new FirefoxDriver();
driver.get("http://somewebapp");
WebElement userElement = driver.findElement(By.xpath("//*ul[@id='treelist']//li[2]//span"));
I tried many ways of editing the xpath, but couldn't succeed. Can someone please help solve this issue?