Selenium xpath not found

I tried the xpath("//*[@id='btn-conv-view']") to click button in selenium web driver java code and it didn’t seem to work. The html is below:

<button id="btn-conv-view" class="btn btn-absolute btn-view-dd" role="button" tabindex="-1" aria-haspopup="true" title="More view options" data-action="menu"> 
    <span class="icon-text" id="yui_3_16_0_1_1443572970628_2273">Sort by date</span>
    <b class="icon icon-chevron-down" id="yui_3_16_0_1_1443572970628_2377"></b>
</button>

Answer

you can use any of this ways to find element you needed:

driver.findElement(By.id("btn-conv-view")).click();

driver.findElement(By.xpath("id('btn-conv-view')")).click();

driver.findElement(By.CssSelector("#btn-conv-view")).click();

Leave a Reply

Your email address will not be published. Required fields are marked *