t
Frequently Asked Questions
Watij API
Confirm popup dialog
The trick to it right now is to use a separate thread. You can do this in two different ways. Let’s say you have a button with name=Confirm that when clicked will popup a confirm dialog. Here are the two ways you can handle this: 1) Put sendKeys on a separate thread - it will wait until the dialog is present:
new Thread(new Runnable() { public void run() { try { ie.sendKeys("Microsoft Internet Explorer", " "); } catch (Exception e) { } } }).start(); ie.button("Confirm").click();
2) Put the action that will cause the popup on a separate thread:
new Thread(new Runnable() { public void run() { try { ie.button("Confirm").click(); } catch (Exception e) { } } }).start(); ie.sendKeys ("Microsoft Internet Explorer", " ");
As you can see sending a space will click the OK button...if you want to click the Cancel button just send a tab with a space (e.g. “{TAB} “). Also note that you may have to put a Thread.sleep after you start the first thread b/c there is no guarantee that the Thread has started before the next thread begins. In a future release we plan to add an api that will make handling popup javascript windows a lot easier. For now the above should work.
Watij BeanShell
UnsatisfiedLinkError in IntelliJ
Watij uses Jacob as its underlying Java-COM bridge, which only allows one classloader at a time to load the jacob.dll. BSFConsole creates a classloader for each console, which is why you are receiving this erorr.
Workaround:
- Setup a separate Module in IntelliJ (call it BSFConsoleClasspath) and include all the jars except jacob.jar. Have the BSFConsole point to this module’s classpath.
- Add jacob.jar to the /BSFConsole/lib dir - this will force BSFConsole to only load Jacob once.
Note: The BSFConsole plugin folder for IntelliJ is typically located under C:/Documents and Settings/\[User\]/.IntelliJIdea50/config/plugins/BSFConsole