<span ng-click="addReqPage()" class=" wrapper-xs text-center cursor-pointer" tooltip-placement="bottom" data-toggle="tooltip" tooltip="Add Specification"> 
    <!-- ngIf: is_create_requirement -->
        <i class="mdi mdi-plus  ng-scope" ng-if="is_create_requirement"></i>
    <!-- end ngIf: is_create_requirement --> 

<i class="mdi mdi-plus  ng-scope" ng-if="is_create_requirement"></i>

I tried this but not working

element = driver.findElement(By.xpath("//[@id=\"appview\"]/div[5]/div/div[2]/div[2]/div[2]/span[1]/i"));
  • Code which you have commented doesn't contains any button. – Bharadwaj Pendyala Feb 22 '18 at 13:28
  • 1
    you need to provide the rest of your HTML. you are only showing us the very last part of what the XPath is selecting. you could have an issue between where it selects the element with the ID and where it selects one of the many div's you have listed before the span – Malachi Feb 22 '18 at 13:36
  • 5
    What exactly is failing? Your xpath attempts to locate an italics element, and it is there, but there's no text associated with it. As @Bradz mentioned, there is no button or clickable element in that locator. Are you getting nul returned for the element or some other error when you try to click it? – Bill Hileman Feb 22 '18 at 14:38

I found a StackOverflow question that is similar to yours and I think it might help you out even though we do not have all the HTML.

element = driver.findElement(By.xpath("//[@id=\"appview\"]/div[5]/div/div[2]/div[2]/div[2]/span[1]/i"));

you are missing the Tag Declaration before specifying the id (Please Refer to this Answer)

Your XPath should look like this, you can also use single quotes instead of escaping doubles

element = driver.findElement(By.xpath("//*[@id='appview']/div[5]/div/div[2]/div[2]/div[2]/span[1]/i"));

although, you should know the tagname of the element with the id='appview' and that is what should be in the XPath instead of the * wildcard, because it is not just any element.

there should be only a single element with each unique ID.(theoretically)

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.