java - HtmlUnit accessing an element without id or Name -


how can access element:

<input type="submit" value="save xml" onclick="some code goes here"> 

more info: have access programmatically web page , simulate clicking on button on it, generate xml file hope able save on local machine.
trying using htmlunit libraries, examples find use getelementbyid() or getelementbyname() methods. unfortunately, exact element doesn't have name or id, failed miserably. supposed thing have use getbyxpath() method got lost xpath documentation(this matter new me).
have been stuck on couple of hours need can get.
in advance.

there several options xpath select input element.

below 1 option, looks throughout document input element has attribute named type value "submit" , attribute named value value "save xml".

//input[@type='submit' , @value='save xml'] 

if provide little bit more structure, more specific (and efficient) xpath created. instance, might work:

/html/body//form//input[@type='submit' , @value='save xml'] 

you should able use xpath code this:

client = new webclient(browserversion.firefox_3) client.javascriptenabled = false  page = client.getpage(url)  submitbutton = page.getbyxpath("/html/body//form//input[@type='submit' , @value='save xml']") 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -