krishan krishan - 1 year ago 83
Java Question

button location error using xpath urgent?

I have to test a dynamic app using i have a button like that

<button class="btn btn-primary btn-mini" ng-click="addAnswer(question)" ng-show="question.editing">Add Answer</button>

i was trying to locate button with that but i failed

getDriver().findElement(By.xpath("//img [@ng-click='addAnswer(question)']")).click();

using css

List AddAnswerBtn =

give me correct line to locate it.. i dont wants to locate it using class and i wants to use xpath to locate button location

Answer Source

Your example shows it is a button, but your XPath is looking for an image:


The above is what you are using, with img as the element type.

Change this to button.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download