Hi,
I am putting the problem statement and exception stacktrace again.
*Test Class* :-
package xyz;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;
import net.sourceforge.jwebunit.junit.WebTestCase;
public class ExampleWebTestCase extends WebTestCase {
public void setUp() {
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
getTestContext().setBaseUrl("http://www.google.com");
}
public void testSearch() throws Exception {
beginAt("/");
setTextField("q", "htmlunit");
submit("btnG");
clickLinkWithText("HtmlUnit");
assertTitleEquals("htmlunit - Welcome to HtmlUnit");
assertLinkPresentWithText("Get started");
}
}
*Exception* :-
[junit] Testcase: testSearch(xyz.ExampleWebTes
tCase): Caused an ERROR
[junit] null
[junit] java.lang.NullPointerException
[junit] at
com.gargoylesoftware.htmlunit.javascript.host.Event.<init>(Ev
ent.java:280)
[junit] at
com.gargoylesoftware.htmlunit.javascript.host.Event.<init>(Ev
ent.java:267)
[junit] at
com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandl
ersIfNeeded(HtmlPage.java:1236)
[junit] at
com.gargoylesoftware.htmlunit.html.HtmlPage.cleanUp(HtmlPage.
java:218)
[junit] at
com.gargoylesoftware.htmlunit.TopLevelWindow.close(TopLevelWi
ndow.java:104)
[junit] at
com.gargoylesoftware.htmlunit.WebClient.closeAllWindows(WebCl
ient.java:1937)
[junit] at
net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.c
loseBrowser(HtmlUnitTestingEngineImpl.java:204)
[junit] at
net.sourceforge.jwebunit.junit.WebTester.closeBrowser(WebTest
er.java:145)
[junit] at
net.sourceforge.jwebunit.junit.WebTestCase.closeBrowser(WebTe
stCase.java:129)
[junit] at
net.sourceforge.jwebunit.junit.WebTestCase.tearDown(WebTestCa
se.java:55)
[junit] at
net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCas
e.java:79)
[BF-ERROR] JUnit Tests Failed
[BF-ERROR] JUnit tests failed
[BF-ERROR] Test xyz.ExampleWebTestCase failed
*Just to highlight* :- i get this exception at the line "beginAt("/");".
Even if i directly begin from "beginAt("http://www.google.com");" , it is
not making any difference to the error.
Also, since JWebUnit picks HTMLUnit plugin by default, it hardly makes a
difference whether we include the line below or not:-
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
Anyways, i think this line is not connected with the exception i am getting.
So we can leave the plugin discussion apart.
It will be great if someone has a clue from where this error is coming. It
has become a big bottleneck from me. Any help will be highly appreciated.
Many Thanks,
Pranay.
On Sat, Jul 25, 2009 at 10:18 AM, Jevon Wright <[email protected]> wrote:
> Hi Pranay,
>
> You shouldn't need to specify which testing engine to use, as it should
> default to HtmlUnit (unless I'm mistaken).
>
> Can you post the rest of the stack trace up to
> ExampleWebTestCase.testSearch()?
>
> Jevon
>
>
> On Sat, Jul 25, 2009 at 1:30 AM, Pranay Prabhat
> <[email protected]>wrote:
>
>> Many Thanks for answers below.
>>
>> As far as any confusion with regards the source code , then i think we can
>> neglect those as of now because right now i am only trying to focus on a
>> standard jwebunit code which i shall be able to run.
>>
>> I have all the required jars in my class path which includes htmlunit-2.5
>> and nekohtml 1.9.12. Secondly i am not sure whether we need to explicitly
>> specify the code for HTMLUnit plugin as i am not using Selenium Plugin and
>> therefore the jwebunit test should pick the HTMLUnit plugin by default.
>>
>> Even if i run a standard test class below :
>>
>> package xyz;
>> import net.sourceforge.jwebunit.util.TestingEngineRegistry;
>> import net.sourceforge.jwebunit.junit.WebTestCase;
>> public class ExampleWebTestCase extends WebTestCase {
>>
>> public void setUp() {
>>
>> setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
>> getTestContext().setBaseUrl("http://www.google.com");
>> }
>>
>> public void testSearch() throws Exception {
>> beginAt("/");
>> setTextField("q", "htmlunit");
>> submit("btnG");
>> clickLinkWithText("HtmlUnit");
>> assertTitleEquals("htmlunit - Welcome to HtmlUnit");
>> assertLinkPresentWithText("Get started");
>> }
>> }
>>
>> I face the problem :-
>>
>> junit] ------------- ---------------- ---------------
>> [junit] Testcase:
>> testSearch(com.bamnetworks.mobile.event.test.ExampleWebTes
>> tCase): Caused an ERROR
>> [junit] null
>> [junit] java.lang.NullPointerException
>> [junit] at
>> com.gargoylesoftware.htmlunit.javascript.host.Event.<init>(Ev
>> ent.java:280)
>> [junit] at
>> com.gargoylesoftware.htmlunit.javascript.host.Event.<init>(Ev
>> ent.java:267)
>> [junit] at
>> com.gargoylesoftware.htmlunit.html.HtmlPage.executeEventHandl
>> ersIfNeeded(HtmlPage.java:1236)
>>
>> Please can you suggest what is the problem here.
>>
>> Many Thanks,
>> Pranay.
>>
>> On Thu, Jul 23, 2009 at 6:27 PM, Julien HENRY <[email protected]> wrote:
>>
>>> I second Francois concerning code source, even if I'm not sure this is
>>> the root cause of the given error, it will lead to future issues.
>>>
>>> ------------------------------
>>> *De :* Fran coyy <[email protected]>
>>> *À :* Usage problems for JWebUnit <[email protected]>
>>> *Envoyé le :* Jeudi, 23 Juillet 2009, 14h52mn 09s
>>> *Objet :* Re: [JWebUnit-users] Problem while running JwebUnit tests
>>>
>>> Also the setUp fonction must be something like this :
>>>
>>> public void setUp() {
>>> try {
>>> super.setUp();
>>> } catch (Exception e) {
>>>
>>> }
>>>
>>> setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); // use
>>> HtmlUnit
>>> }
>>>
>>>
>>>
>>> Francois
>>>
>>>
>>>
>>> On Thu, Jul 23, 2009 at 2:50 PM, Fran coyy <[email protected]> wrote:
>>>
>>>> Hello,
>>>>
>>>> I'm not sure it can help you, but my own tests are working like this :
>>>>
>>>>
>>>> public void testIdentification(String login, String password) {
>>>> beginAt(PropertyConfManager.getValue("URL_BASE"));
>>>>
>>>> assertFormPresent(PropertyConfManager.getValue("FORMULAIRE_IDENTIFICATION"));
>>>>
>>>> setTextField(PropertyConfManager.getValue("FORMULAIRE_IDENTIFICATION_LOGIN"),
>>>> login);
>>>>
>>>> setTextField(PropertyConfManager.getValue("FORMULAIRE_IDENTIFICATION_PASSWORD"),
>>>> password);
>>>> submit();
>>>> }
>>>>
>>>> I think you don't need to create all these objects you're creating.
>>>>
>>>>
>>>> Good luck,
>>>>
>>>> Francois
>>>>
>>>>
>>>> On Thu, Jul 23, 2009 at 1:47 PM, Pranay Prabhat <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Day before yesterday i was browsing through internet to find out the
>>>>> best possible testing framework for web applications in my project. I was
>>>>> really impressed by the postings in JwebUnit and tried to implement that
>>>>> rightaway in my projects.
>>>>>
>>>>> But i landed in a problem and was not able to come out of it for more
>>>>> than a day.
>>>>>
>>>>> I have put all the jars provided in the jwebunit-2.2-release.zip in my
>>>>> class path. I am running the below simple test case through ant 1.6.5. I
>>>>> always get the below error :-
>>>>>
>>>>> " [junit] unable to create HTML parser
>>>>> [junit] com.gargoylesoftware.htmlunit.ObjectInstantiationException:
>>>>> unable to create HTML parser"
>>>>>
>>>>> " [junit] Enclosed exception: org.xml.sax.SAXNotRecognizedException:
>>>>> Feature '
>>>>> http://cyberneko.org/html/features/parse-noscript-content' is not
>>>>> recognized."
>>>>>
>>>>>
>>>>>
>>>>> The simple junit i am running is :-
>>>>>
>>>>> package xyz;
>>>>>
>>>>> import net.sourceforge.jwebunit.junit.WebTestCase;
>>>>> import net.sourceforge.jwebunit.junit.WebTester;
>>>>>
>>>>>
>>>>> public class ExampleWebTestCase extends WebTestCase {
>>>>> private WebTester tester;
>>>>> public void setUp() throws Exception {
>>>>> super.setUp();
>>>>> tester = new WebTester();
>>>>> tester.setBaseUrl(<<<my url>>>);
>>>>> }
>>>>>
>>>>> public void test1() {
>>>>> tester.beginAt("/");
>>>>> tester.assertTextPresent("Group");
>>>>> }
>>>>> }
>>>>>
>>>>> Any help will be highly appreciated.
>>>>>
>>>>> Thanks,
>>>>> Pranay.
>>>>>
>>>>>
>>>>>
>>>>> ------------------------------------------------------------------------------
>>>>>
>>>>> _______________________________________________
>>>>> JWebUnit-users mailing list
>>>>> [email protected]
>>>>> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>>>>>
>>>>>
>>>>
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> JWebUnit-users mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>>
>> _______________________________________________
>> JWebUnit-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>>
>>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> JWebUnit-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jwebunit-users
>
>
------------------------------------------------------------------------------
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users