Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Problem in HtmlUnitDriver Output in Selenium WebDriver

View previous topic View next topic Go down

Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Tue Jun 04, 2013 5:08 pm

Hi,

I am trying to run my test scripts in Htmlunit Driver. But not able to get correct response.

Here is my sample code:

Code:
import org.junit.Assert;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class MyFirstClass {

 public static void main(String[] args) throws InterruptedException {
   
    HtmlUnitDriver myDriver = new HtmlUnitDriver();
    myDriver.get("[url=http://www.google.com]http://www.google.com[/url]");
        System.out.println("What is my URL --------------->" + myDriver.getCurrentUrl());
        System.out.println("What is my Page title ----------->" + myDriver.getTitle());
        myDriver.quit();
    }
}



I am not getting any error.But my output is



[size=16]

What is my URL --------------->about:blank

What is my Page title ----------->

tats all...

I dont know what went wrong..But the same script is running well n Good in Firefox Driver.

Please help.

Thanks,

Vidya

[/size]

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by Ganesh D on Wed Jun 05, 2013 9:11 pm

M also getting same problem with HtmlUnitDriver. I wrote one script, which does the login. But it works fine in firefox and IE, getting problem when I used HTMLUnitDriver. How can we use it ? Does anyone have any idea ?

Please reply fast.

Ganesh D

Posts : 1
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by mail2prassad on Tue Jun 18, 2013 4:22 am

There was no issue running code and I can see the correct output using HtmlUnitDriver.
What version of Webdriver you are using.

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Tue Jun 18, 2013 12:26 pm

I donno how to check the version.
I am using the following jar files.
selenium-server-standalone-2.25.0.jar
selenium-java-2.25.0-srcs.jar
selenium-java-2.25.0.jar
selenium-htmlunit-driver-2.32.0.jar

I think i ve downloaded almost the latest version ly.
Did u able to get output for this htmlUnit driver code ??
Can u tell wat version do i ve to use ??

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by mail2prassad on Tue Jun 18, 2013 8:15 pm

The number before the .jar is the version number.
Remove the following jars in the classpath and try again.
selenium-server-standalone-2.25.0.jar
selenium-java-2.25.0-srcs.jar
selenium-htmlunit-driver-2.32.0.jar

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Wed Jun 19, 2013 8:44 pm

Thanks prassad.
I tried whatever u said ,still din get the output.

Sry i ve few basic doubts...
u told to remove some jars frm classpath ryt ??

Do u mean Computer->properties-->Advanced -->Environment variables-->classpath ??
or
In Eclipse Build java path ??

Anyways i tried in both the ways din get the response yet...

Please can u explain watall u ve used in urs..

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by mail2prassad on Wed Jun 19, 2013 9:04 pm

If you are using eclipse then modify the eclipse build path and if you are using command line to run the program then modify the other.

I'm using selenium-java-2.25.0.jar only. It looks like the driver is not loading the web page in your case.
Can you try adding the line System.out.println(myDriver.getPageSource());
after
myDriver.get("http://www.google.com");
and see whether that prints the correct source.

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Thu Jun 20, 2013 12:34 pm

Prassad,
U told to remove few jars ryt ..
If i removed the selenium-server-standalone-2.33.0.jar, den am getting this error..

Exception in thread "main" java.lang.NoClassDefFoundError: com/gargoylesoftware/htmlunit/WebWindowListener
 at myTestPackage.MyFirstClass.main(MyFirstClass.java:14)
Caused by: java.lang.ClassNotFoundException: com.gargoylesoftware.htmlunit.WebWindowListener
 at java.net.URLClassLoader$1.run(Unknown Source)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
 at java.lang.ClassLoader.loadClass(Unknown Source)
 ... 1 more

And if i used the following jars
1) selenium-server-standalone-2.33.0.jar
2) selenium-java-2.33.0.jar
then i am getting this output...

Code:
<?xml version="1.0" encoding="UTF-8"?>
<html>
 <head/>
 <body/>
</html>

What is my URL --------------->about:blank
What is my Page title ----------->

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Thu Jun 20, 2013 12:49 pm

U r ryt prassad. HtmlUnitDriver is not loading the webpage.
Wen i tried the same in Firefox, am getting the source code.

Sorry, i am hving few more basic doubts...
I my case,Without selenium-server-standalone-2.33.0.jar file , i cudnt get any output even in other browsers( Firefox ,IE..). Even i dont need to add selenium-java-2.33.0.jar file.

But u told that u r using selenium-java-2.33.0.jar file alone ??
I dont understand Y so ?? and wats wrong in my approach ??
R u using cmd line or Eclipse ??

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Thu Jun 20, 2013 1:21 pm

FYI
Same issue posted by someelse..

http://stackoverflow.com/questions/11248300/htmlunitdriver-not-getting-page-properly

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by mail2prassad on Fri Jun 21, 2013 5:47 pm

selenium-java-***.jar is enough to run your tests locally and this contains all the WebDriver related stuff. If you are trying to run tests remotely you may need selenium-server-standalone-***.jar.

Can you try using HtmlUnitDriver myDriver = new HtmlUnitDriver(true); instead of HtmlUnitDriver myDriver = new HtmlUnitDriver();


OR


HtmlUnitDriver myDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3); instead of HtmlUnitDriver myDriver = new HtmlUnitDriver();


Last edited by mail2prassad on Fri Jun 21, 2013 7:33 pm; edited 2 times in total

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by mail2prassad on Fri Jun 21, 2013 5:55 pm

Hello,
I'm new to Testing. I've tried to learn WebDriver without any knowledge of Manual Testing. I got few queries. If possible can you help me clarify my queries and any help is very much appreciated.

What is the type of testing that we do with Selenium automation i.e System, Acceptance, Integration, UAT etc., what exactly is it in the real world.

What are the day to day activities of Selenium tester in real world.

Do we need to apply Manual testing fundamentals in automation.

How frequently we use CI tools and what is the scope of CI tools in the context of automation testing.

Thanks.

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Wed Jun 26, 2013 7:01 pm

Prassad,

    I tried
   HtmlUnitDriver myDriver = new HtmlUnitDriver(true); and
   HtmlUnitDriver myDriver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3);

But still din get the response.


Regards,
Vidya

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by vidya shree on Wed Jun 26, 2013 7:16 pm

Hello Prassad,

    Myself aslo new to Testing...But I tried to answer as far i know...,

Mostly we will do only "System Testing" in Automation.
For Autoamtion , u need to know only the work flow/steps,tats all .By using tat v can  do the scripting.
But in Manual testing , v can learn its(Appln) functionality very well.

Do we need to apply Manual testing fundamentals in automation ?

Not neccessary..But learning the functionality is good. In case if u want to do any improvision in scripting in future(any update in ur appln), then this functionality knowledge (Manual testing) helps lot.

I donno about CI tools.

Regards,
Vidya

vidya shree
Regular Participant
Regular Participant

Posts : 31
Join date : 2013-05-09

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by mail2prassad on Thu Jun 27, 2013 4:39 pm

Hi Vidya,

That is great and very much appreciated, that was really helpful.
Thank you very much.

Best,
Prassad

mail2prassad
Amateur
Amateur

Posts : 41
Join date : 2013-06-05

Back to top Go down

Re: Problem in HtmlUnitDriver Output in Selenium WebDriver

Post by Sponsored content Today at 8:53 am


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum