Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Open Source Projects
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Other Open Source Projects
[HtmlUnit] Can't see javascript update to DOM
Jiri Nejedly
Ranch Hand
Posts: 118
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am trying to simulate html page , which reveals some content only by clicking on some element (invoking javascript code). No new page is loaded, only part od DOM is updated.
In HtmlUnit I tried this
WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.setCookieManager(new CookieManager()); HtmlPage page = (HtmlPage)webClient.getPage(url); String sPage = page.getWebResponse().getContentAsString(); HtmlAnchor button = (HtmlAnchor)page.getElementById("some_link"); // javascript:get_links(); is called by link page = button.click(); String sPage2 = page.getWebResponse().getContentAsString(); // ... nothing changed in dom
Please, can somebody help me ? Thanks.
Ulf Dittmer
Rancher
Posts: 43081
77
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Which parts do work, and which parts don't?We'd also need to see the html/javascript that this is about.
Jiri Nejedly
Ranch Hand
Posts: 118
posted 9 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
OK , here's the real example
WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.setCookieManager(new CookieManager()); HtmlPage page = (HtmlPage)webClient.getPage("http://www.hq-music-videos.com/K/klymaxx/klymaxx-hq_video-71505.html"); String sPage1 = page.getWebResponse().getContentAsString(); HtmlAnchor button = (HtmlAnchor)page.getElementById("bg_animation_link"); page = button.click(); String sPage2 = page.getWebResponse().getContentAsString();
The element
<div class="downlinks_container" id="links_container_71505"></div>
is after click on anchor expanded into this (you cannot see href attribute, I cannot paste it)
<div class="downlinks_container" id="links_container_71505"> <ul class="dolinks"> <li><a target="_blank" rel="nofollow">Download from FBoom.me</a> </li> <li><a target="_blank" rel="nofollow">Download from FileJoker.net</a> </li> </ul> </div>
, but variable sPage2 has nothing of this kind.
straws are for suckers. tiny ads are for attractive people.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Java automation to Login to website
ADF MyFaces and HttpUnit testing
Retrieving word lists using htmlunit and xpath
HtmlUnit show content of aspx page (school timetable)
Login to a web forum
More...