new to Watij

59 views
Skip to first unread message

Davina Armstrong

unread,
Oct 21, 2009, 1:16:32 PM10/21/09
to watij
Hi --

I'm new to Watij, and I've been banging my head against the wall
trying to get the simple GoogleTest example to work with Intellij,
with no success. I was successful in running the sample test through
the interactive shell.

I have performed the following steps:
1) Downloaded and extracted watij_release3.0_BETA (NOTE: I started
with 2.0 in which I also saw these results)
2) Copied jniwrap.dll into C:/WINDOWS/system32
3) Created a new project called GoogleTest in IntelliJ
4) Added a lib folder at the same level as src within the project and
copied all jars from lib within Watij to it
5) Added a library to my module pointing to the lib folder created in
(4)
6) Appended all of the jars in lib to my System classpath

The problems I am seeing are as follows:
1) watij.finders.SymbolFactory does not seem to exist
2) IntelliJ suggests I import watij.IE, which I do
3) The app crashes on ie.start("http://www.google.com"); with the
below trace
4) In ie.textField(name, "q"); name is never defined. Why does this
even work in the interactive shell?

If any newbie-tolerant person out there can offer some insight, I'd
very much appreciate it.

java.lang.NoClassDefFoundError: com/tapsterrock/jiffie/WindowListener
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:
124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at watij.IE.start(IE.java:73)
at watij.IE.start(IE.java:68)
at WatijTest.testGoogleSearch(WatijTest.java:10)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.junit.JUnitStarter.main
(JUnitStarter.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:
90)
Caused by: java.lang.ClassNotFoundException:
com.tapsterrock.jiffie.WindowListener
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 38 more

Alexey Bulat

unread,
Oct 22, 2009, 2:19:32 AM10/22/09
to wa...@googlegroups.com
Hi,

It seems that not all required libs are included into your project.

Would be nice if yo list all included libs...

regards,
Alexey

Adrian Ghidu

unread,
Oct 22, 2009, 6:30:32 AM10/22/09
to wa...@googlegroups.com
Alexey is correct. Add all the .jar files from the Watij lib directory to your lib dir.
If you use Eclipse, simply right click on the lib dir, select "Buil Path"/"Configure Build Path". Now go to "Libraries" tab click "Add external jars" and select all the jars from lib. Good luck

Adrian

Adrian Ghidu

unread,
Oct 22, 2009, 6:32:21 AM10/22/09
to wa...@googlegroups.com
Almost forgot, you have to also copy the watij.jar file from the watij directory.

Adrian

Davina Armstrong

unread,
Oct 22, 2009, 3:51:59 PM10/22/09
to watij
I thought I'd responded to this earlier, so if I've posted twice, I
apologize. I am in IntelliJ, and am just as new to it as I am to
WATIJ.

I verified that I'd copied all of the .jar files from Watij's lib
folder to my lib folder. They are:

bsh.jar
comfyj-2.1.jar
jniwrap-3.1.jar
junit.jar
nekohtml.jar
resolver.jar
serializer.jar
watij.jar
watijcom.jar
winpack-3.0.jar
xalan.jar
xercesImpl.jar
xml-apis.jar

The class I'm failing on is com.tapsterrock.jiffie.WindowListener,
which I can't even find online to download. If anyone knows where
that is (or has other suggestions), again I'd be appreciative.

Thanks,
Davina

Darrell Grainger

unread,
Oct 23, 2009, 8:24:35 AM10/23/09
to wa...@googlegroups.com
There is something in your environment that is not required for basic
Watij usage. I am using Eclipse with Watij and do not have the
com.tapsterrock.jiffie package installed. You should not need JIFFIE.

JIFFIE (Java InterFace For Internet Explorer) looks to be a dead
project on SourceForge (http://sourceforge.net/projects/jiffie/).
Version 1.0 was release almost 2 years ago. The official site for it,
http://www.tapsterrock.com/jiffie/, is dead. Someone is
cyber-squatting the address.

I think your solution is NOT to add an unnecessary library to your.
You should be figuring out why your set up thinks it is needed.

Darrell

2009/10/22 Davina Armstrong <dstar...@gmail.com>:

Davina Armstrong

unread,
Oct 23, 2009, 2:03:22 PM10/23/09
to watij
OK, I solved my JIFFIE problem. I had the watij 2.0 .jar file in my
lib, and it used JIFFIE. It also didn't have the
watij.finders.SymbolFactory class required by the quick start
tutorial, which is

import junit.framework.TestCase;
import static watij.finders.SymbolFactory.*;

public class GoogleTest extends TestCase {
public void testGoogleSearch() throws Exception {
IE ie = new IE();
ie.start("http://www.google.com");
ie.textField(name,"q").set("Watij");
ie.button("Google Search").click();
assertTrue(ie.containsText("/Web Application Testing in
Java/"));
}
}

I'm having the following issues:
1) Import Watij.IE is required to instantiate the IE class (but isn't
in the sample code, leaving me wondering if I'm doing something wrong
2) After instantiating ie, ie.ieController is null, causing the app to
crash on ie.start()

Thanks for your incredibly prompt help so far, and I hope someone can
help me figure this one out!

Davina

Darrell Grainger

unread,
Oct 23, 2009, 2:19:38 PM10/23/09
to wa...@googlegroups.com
The package for the IE class does need to either be imported or all
instances of IE need to be fully qualified. The sample code is missing
this fact.

I have not seen the issue with ie.ieController before. Did you have a
look at http://www.watij.com/wiki:quick_start. Hopefully there is
something there you are missing.

Darrell

2009/10/23 Davina Armstrong <dstar...@gmail.com>:

Liron Lichterman

unread,
Oct 23, 2009, 3:34:41 PM10/23/09
to wa...@googlegroups.com
Try to see if your defalut browser is IE


Davina

--
Liron Lichterman

ds tara

unread,
Oct 23, 2009, 3:55:15 PM10/23/09
to wa...@googlegroups.com
Liron -- I'm not sure what you mean by the default browsers, but it is set to IE in my IDE.


I'm reading the watij.IE code, and the constructor doesn't do anything

public IE() {
}

There is a private constructor that sets the ieController property, but I don't know where that ieController would be created, or where this constructor would be called.  So based on what I'm reading, the behavior I'm seeing is what I'd expect.  So how is it supposed to work?!  I know I'm missing something...

Davina

Liron Lichterman

unread,
Oct 24, 2009, 12:25:54 AM10/24/09
to wa...@googlegroups.com
i had this problem as well. if you put URL in the command line prompt, does it open IE?

Adrian Ghidu

unread,
Oct 25, 2009, 4:20:00 AM10/25/09
to wa...@googlegroups.com
Did you copy the .dll file to the windows path (like C:\Windows\system32)? The file name should be jniwrap.dll.

Adrian Ghidu

unread,
Oct 25, 2009, 4:21:06 AM10/25/09
to wa...@googlegroups.com
Please ignore, I didn't have the latest version of this forum.

Madieyna Lamine Fall

unread,
Oct 26, 2009, 9:12:39 AM10/26/09
to wa...@googlegroups.com
Hello Liron
 
I'm not a Watij expert but
1) do you include watij.jar in your classpath ?
2) Did you import IE ( "watij.runtime.ie.IE") in your code ? (necessary to instantiate IE class )
3) Do you include all the jars that came with watij (in watij_release_3.1.0\lib directory) ?
4) Did you place the dll file ("jniwrap.dll") in C:/windows/System32 ?
 
all the jars are java archives containing all the needed classes.
hope I answered/clarified your question !!!
 
Have a nice one
 
Lamine

Davina Armstrong

unread,
Oct 27, 2009, 6:48:16 PM10/27/09
to watij
Liron --

Yes, everything worked as expected when I ran watij from BeanShell.
IE launched just fine. Do you know the solution to my scripting
problem?

Lamine --

Yes, I did everything you listed, but I still get the NPE.

Thanks,
Davina

Liron

unread,
Oct 28, 2009, 2:44:42 AM10/28/09
to wa...@googlegroups.com
Just to make sure, your IE is the default browser, when you put url in the
command line and enter it you are getting IE browser?

boltick

unread,
Oct 28, 2009, 4:17:09 AM10/28/09
to watij
What if you change your code to the following:

public class GoogleTest extends TestCase {
public void testGoogleSearch() throws Exception {
IE ie = new IE();
ie.start();
ie.goTo("http://www.google.com");
ie.textField(name,"q").set("Watij");
ie.button("Google Search").click();
assertTrue(ie.containsText("/Web Application Testing in
Java/"));
}
}

Will you get the same NPE? In what line? Please post stacktrace of the
NPE...

Alexey

Davina Armstrong

unread,
Oct 30, 2009, 10:52:07 AM10/30/09
to watij
Yay! ie.start() fixed the problem with the NPE on ie.goto(). The
next problem is with ie.textField(name, "q").set("Watij"). What is
name? Where does it come from? The compiler chokes on it.

Alexey Bulat

unread,
Oct 30, 2009, 12:08:54 PM10/30/09
to wa...@googlegroups.com
Hello,

Try this:
...

ie.start();
ie.goTo("http://www.google.com");
ie.textField(FinderFactory.name("q")).set("Watij");

ie.button("Google Search").click();
assertTrue(ie.containsText("/Web Application Testing in Java/"));
...

regards,
Alexey

Davina Armstrong

unread,
Oct 30, 2009, 12:14:00 PM10/30/09
to watij
Alexey, thanks so much for your help. Using FinderFactory allows the
code to compile, but it never reaches the ie.textField... line - it
hangs after opening the browser. Any thoughts?

On Oct 30, 9:08 am, Alexey Bulat <alexeybu...@gmail.com> wrote:
> Hello,
>
> Try this:
> ...
> ie.start();
> ie.goTo("http://www.google.com");
> ie.textField(FinderFactory.name("q")).set("Watij");
> ie.button("Google Search").click();
> assertTrue(ie.containsText("/Web Application Testing in Java/"));
> ...
>
> regards,
> Alexey
>

Darrell Grainger

unread,
Oct 30, 2009, 12:14:44 PM10/30/09
to wa...@googlegroups.com
If you look at the source code for the web page you will see the element:

<input name='q'/>

So ie.textField(name, "q") is locating the input tag. The (name, "q")
requires you to include the proper package:

import static watij.finders.SymbolFactory.*;

There is also the format ie.textField(name("q")) which requires:

import static watij.finders.FinderFactory.*;

Darrell


2009/10/30 Davina Armstrong <dstar...@gmail.com>:

Madieyna Lamine Fall

unread,
Oct 30, 2009, 4:04:56 PM10/30/09
to wa...@googlegroups.com
Hello Davina
 
ie.start();

==>when you check the source page of google.com ( right click on page and select "view source page") you'll be able to see the following line for the textfield :

<input autocomplete="off" maxlength=2048 name=q size=55 class=lst title="Recherche Google" value="">

Hope it helps
 
Dieyna

Reply all
Reply to author
Forward
0 new messages