Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:23:59+00:00 2026-06-10T21:23:59+00:00

I have written a selenium script which runs in java : String pageName =

  • 0

I have written a selenium script which runs in java :

    String pageName = "my test url which invloves an link to html which has javscript excution";
    logger.log(Level.INFO,"Page name : " + pageName);
    WebDriver driver = new HtmlUnitDriver(true);

    logger.log(Level.INFO,"driver instance created " );
    String str ="";

    logger.log(Level.INFO,"opening the url now.... " );
    driver.get(pageName);
    logger.log(Level.INFO,"url is now opened :: url = "+driver.getCurrentUrl());
    logger.log(Level.INFO,"driver now going to sleep = "+driver.getCurrentUrl());
    Thread.sleep(150000);

    logger.log(Level.INFO,"Wake up from sleep now....");
    logger.log(Level.INFO,"URL ::"+driver.getCurrentUrl());
    logger.log(Level.INFO,"PageSource ::"+driver.getPageSource());
    try {
        logger.log(Level.INFO,"Driver going to wait now...");
        driver.wait(100000);
        logger.log(Level.INFO,"Driver came out of wait now normally...");
    } catch (Exception e) {
        logger.log(Level.INFO,"Driver came out of wait now exception::"+e);
    }

    logger.log(Level.INFO,"driver instance task completed " );
    logger.log(Level.INFO,driver.getCurrentUrl());

    logger.log(Level.INFO,driver.getCurrentUrl());
    logger.log(Level.INFO,str);

    driver.close();

Now when I debug this code I get my proper result but when I run this piece of code from servlet I get only the html content not the proper content which is excepted to come from the given link.

I also tried using the firefox driver and the same code works fine with it.
I also tried the same code with Web client but the same problem is coming.

Can anyone help me with this exception?

Thanks,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:24:00+00:00Added an answer on June 10, 2026 at 9:24 pm

    When you debug the code, you can halt at checkpoints. But you cannot stop browser from loading. It loads itself independently.
    Htmlunitdriver pagesource returns all html contents as it cannot execute javascript completely.If the htmlpage contains Ajax, javascript calls then it shows the calls as it is .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written an Ant target that starts Selenium server, runs my test code,
I have a test suite DLL written in C# that uses Selenium.This is then
I have written a bash script which installs a number of packages, however for
have written a stochastic simulation in Java, which loads data from a few CSV
I have written a Java program which I package and run from a JAR
I have written a web-service (in Java) which produces as a result a (rather
I use selenium-rc to test an asp.net website, test script is written in Python
I am using WebDriver with Java for test automation. I have the following HTML
I have multiple functional tests written as NUnit test which are independent from each
I have following methods of my class Test : (Selenium RC, JUnit, Java, Eclipse)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.