1
votes

I am trying to develop automatioed testing scripts for my wicket (frame work) base web application.

I am using Selenium 2.44 jars (plugin) and Firefox 23 version and also using Firefox addons, Firebug for inspecting the web elements and FirePath to get the xpath of web elements. But the problem I am facing is the HTML IDs in my web application are dynamic, which means every time it is changing, so because of which xpaths are also changing and while finding element I am getting "NoSuchElementException".

2
Use a css selector.Please add view examples with the id values if you need any help with the selector. - lauda

2 Answers

3
votes

You set setComponentPathAttributeName() in your DebugSettings. That will cause wicket to render it's path into the html. The path should only change if you change your Component hierarchy.

public void init() {
    super.init();

    getDebugSettings().setComponentPathAttributeName("wicketpath");
}

This will cause your html to look like:

<form wicket:id="form" id="form1" wicketpath="form" method="post" action="./?0-3.IFormSubmitListener-form">
<div wicket:id="childField" wicketpath="form_childField"></div>
</form>
0
votes

It will be good if you provide the snippet of html source of your page. For now I can just suggest that, you can try for some dynamic Xpath functions like contains(), following() etc. just for example: By.xpath("//div[contains(text(),'some text') and contains(@class,'entire class name or some part of class name which is not changing if its dynamic')]/following::*") Or By.xpath("//div[contains(text(),'some text') and contains(@class,'entire class name or some part of class name which is not changing if its dynamic')]/following::div")

like this.