Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Joe Ess
  • salvin francis
  • fred rosenberger

HTML-Unit Website Manipulation

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm back at trying to get HTMLUnit working and I was able to implement it into the project but I'm having some difficulties with it.. I want to track a package via DHL's website and it gives me an error in the console. The whole purpose is for the program to insert the DHL tracking number in the tracking text box, and then for the program to "click" the search button and get the tracking results. I am aware of DHL's API, but this is a school project and I'm trying to learn how to do something like this.

Here is my current code:

This is the error I get in the console:

Apr 23, 2015 7:55:49 PM addbehavior
WARNING: Unimplemented behavior: #default#userdata
Exception in thread "main" com.gargoylesoftware.htmlunit.ElementNotFoundException: elementName=[*] attributeName=[name] attributeValue=[sbtc]
at com.gargoylesoftware.htmlunit.html.HtmlPage.getElementByName(
at htmlTest.main(

Any insight will be greatly appreciated!
Posts: 14758
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you look more closely at the page source, the textarea for entering tracking numbers on that page has a name of "AWB" and an id of "AWB_crossrefpar1_taskcenter_taskcentertabs_item1229046233349_par_expandablelink_insideparsys_fasttrack".

And if you study the horrific JavaScript code on that page, you'll see that they are using document.getElementById(), not getElementByName()

It's horrific JavaScript code because there's a lot of copy-paste programming going on there.
Posts: 67463
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have broken the long lines in your post. Please note how to do it.
This is not a “beginning” topic, so I shall move it.
Hey, I'm supposed to be the guide! Wait up! No fair! You have the tiny ad!
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!