Hi team , I am beginner in selenium webdriver and i am facing Unable to locate element issue ?? can anyone please help ?


Below is the HTML code for the button that I am trying to click , there is no id or name or any other pointer mentioned in the code , I have tried xpath where it does pass the code without failure but does not click the element , I tried css selector and xpath and nothing seems to be working

syntax for web driver using css selector

WebElement element= driver.findElement(By.cssSelector(“#Install new alarm”));

<a href=”#/forms/install>
<button class=” bb-btn btn>
<span class=”ng-scope>Install new alarm</span>
Please let me know if need more info ..thanks
Default Asked on April 19, 2017 in Selenium WebDriver.
Add Comment
  • 2 Answer(s)
    Best answer

    Try below code. Here I am assuming that “Install new alarm” text appears only once in entire web page.


    WebElement element=driver.findElement(By.xpath(“.//span[contains(text(),’Install new alarm’)]”));

    Train Answered on May 16, 2017.
    Add Comment

    class and href are present .. you can use those…make sure the button is enabled… if u have then gotta look into it.

    Can you send the url for the page so that i can reproduce and check it? 🙂

    Supporter Answered on April 19, 2017.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.