Hi Emerson, Try adding something like this to your Javascript:
if (!tinyMCE) alert("tinyMCE has not been loaded yet"); This might help in debugging why your tinyMCE implementation isn't working. If you insert the tiny_mce.js file directly inline your script, does it work then? setExpectedJavaScriptConfirm(String[], boolean[]) checks for expected confirm boxes in the order provided in the array. Are you sure your confirmation boxes are coming up correctly? In Firefox at least, a confirm order A B C will actually appear as C B A in a browser (since they pop over each other), but you will have to specify them as A B C in JWebUnit. Otherwise, try checking the stacktrace of your exception. Hope this helps, Jevon On Mon, Jan 4, 2010 at 11:39 PM, emerson sanchez <es_sanch...@yahoo.com>wrote: > Hi Jevon, > Thanks for your suggestion about the confirm box. Its now working, > thanks to you. I just still can't fix the issue with tinyMce. I tried to > include the ff code at the head section of my jsp to make sure it is defined > before it was loaded but I still got the exception. Please check if what I > did was wrong. > > <head> > <script type="text/javascript" src="/scripts/tinymce/tiny_mce.js"></script> > <script language="javascript" type="text/javascript"> > tinyMCE.init({ > mode : 'textareas', > theme : "advanced", > /*plugins : "advimage",*/ > theme_advanced_buttons1_add_before : "save,separator", > theme_advanced_buttons1_add : "fontselect,fontsizeselect", > theme_advanced_buttons2_add : > "separator,insertdate,inserttime,preview,zoom,separator,forecolor,backcolor", > theme_advanced_buttons2_add_before: > "cut,copy,paste,separator,search,replace,separator", > theme_advanced_buttons3_add_before : "tablecontrols,separator", > theme_advanced_buttons3_add : > "emotions,iespell,flash,advhr,separator,print", > theme_advanced_toolbar_location : "top", > theme_advanced_toolbar_align : "left", > theme_advanced_path_location : "bottom", > plugin_insertdate_dateFormat : "%Y-%m-%d", > plugin_insertdate_timeFormat : "%H:%M:%S", > extended_valid_elements : > "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]", > external_link_list_url : "", > external_image_list_url : "", > flash_external_list_url : "", > }); > </script> > </head> > > I also want to ask another question. How can I set the expected two > consecutive confirm boxes? I tried the method that requires a string array > and a boolean array (setExpectedJavaScriptConfirm(String[], boolean[])) but > it didnt work. I got the same exception as before with this. Can you help me > out a little further? > > Thanks a lot in advance, > Emerson > > > Check me out! <http://www.myspace.com/emersonsanchez> > > --- On *Tue, 22/12/09, Jevon Wright <je...@jevon.org>* wrote: > > > From: Jevon Wright <je...@jevon.org> > Subject: Re: [JWebUnit-users] Issues running JWebUnit test (tinyMce and > javascript Confirm box) > To: "Usage problems for JWebUnit" <jwebunit-users@lists.sourceforge.net> > Date: Tuesday, 22 December, 2009, 7:35 PM > > > Hi Emerson, > > For your first exception, it looks like it is being thrown when the page is > accessed. It looks like the "tinyMCE" variable is not defined. Can you debug > your script to make sure that it is defined before it is loaded? We use > HtmlUnit natively and it appears this supports TinyMCE without any problems, > so it may be a problem with your setup. > > For your second exception, you need to set the expected prompt _before_ > navigating away from the page: > > setExpectedJavaScriptConfirm("You are about to remove BrandService(s) > from this site. Continue?",true); // before navigating away > > checkCheckbox("selectedBrandServiceIds"); > > clickButtonWithText("Remove"); > > Hope this helps > Jevon > > On Fri, Dec 18, 2009 at 7:01 PM, emerson sanchez > <es_sanch...@yahoo.com<http://mc/compose?to=es_sanch...@yahoo.com> > > wrote: > >> Hi, >> I'm having some issues using JWebUnit. I'm using version 2.1. First is, >> I wasn't able to fill in a textarea which implements tinyMce. Although the >> build was successful, it throws an exception and the text I typed wasn't >> saved. Another is that I can't configure JWebUnit to answer yes to a >> javascript confirm box. I have a code that clicks a button which then >> triggers a confirm box. As I checked the mailing list, there are some who >> has the same problem as I mine but AFAIK they didn't find a solution yet. >> Are these issues fixed already that I just can't make my own code work? >> >> Here is the code regarding the textarea issue >> setTextField("h1SearchText", "Configurable H1 Text"); //this is >> the textarea >> >> clickButton("saveH1Search"); //this >> is a submit button >> >> Here is the exception. >> Caused by: org.mozilla.javascript.EcmaError: ReferenceError: "tinyMCE" is >> not defined. (JavaScriptBackgroundJob#1) >> at >> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3558) >> >> at >> org.mozilla.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3536) >> >> at >> org.mozilla.javascript.ScriptRuntime.notFoundError(ScriptRuntime.java:3621) >> at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1653) >> >> at >> org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3413) >> at >> org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484) >> at >> org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) >> >> at >> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) >> at >> com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:170) >> >> at >> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004) >> at >> org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:175) >> >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$5.doRun(JavaScriptEngine.java:396) >> >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:522) >> >> --------------------------------------------------------------------------------------------------------------------------------------------------- >> >> Here is the code for the confirm box. >> >> checkCheckbox("selectedBrandServiceIds"); >> >> clickButtonWithText("Remove"); >> setExpectedJavaScriptConfirm("You are about to remove BrandService(s) from >> this site. Continue?",true); >> >> Exception: >> Tests run: 12, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 56.734 >> sec <<< FAILURE! >> testRemoveBrandServiceFromSite(com.voxsant.pcs.jwebunit.WebTest) Time >> elapsed: 7.704 sec <<< ERROR! >> java.lang.RuntimeException: com.gargoylesoftware.htmlunit.ScriptException: >> Wrapped >> net.sourceforge.jwebunit.exception.UnexpectedJavascriptConfirmException: A >> unexpected confirm with message [You are about to remove BrandService(s) >> from this site. Continue?] was displayed (script in >> http://localhost:8080/edit-site.html?id=1 from (471, 32) to (668, >> 10)#532) >> at >> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.clickButtonWithText(HtmlUnitTestingEngineImpl.java:1886) >> >> at >> net.sourceforge.jwebunit.junit.WebTester.clickButtonWithText(WebTester.java:2530) >> >> at >> net.sourceforge.jwebunit.junit.WebTestCase.clickButtonWithText(WebTestCase.java:2029) >> >> at >> com.voxsant.pcs.jwebunit.WebTest.testRemoveBrandServiceFromSite(WebTest.java:551) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> at junit.framework.TestCase.runTest(TestCase.java:168) >> at junit.framework.TestCase.runBare(TestCase.java:134) >> at >> net.sourceforge.jwebunit.junit.WebTestCase.runBare(WebTestCase.java:79) >> at junit.framework.TestResult$1.protect(TestResult.java:110) >> at junit.framework.TestResult.runProtected(TestResult.java:128) >> at junit.framework.TestResult.run(TestResult.java:113) >> at junit.framework.TestCase.run(TestCase.java:124) >> at junit.framework.TestSuite.runTest(TestSuite.java:232) >> at junit.framework.TestSuite.run(TestSuite.java:227) >> at >> org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81) >> >> at >> org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62) >> >> at >> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140) >> >> at >> org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127) >> >> at org.apache.maven.surefire.Surefire.run(Surefire.java:177) >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> at >> org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345) >> >> at >> org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009) >> >> Caused by: com.gargoylesoftware.htmlunit.ScriptException: Wrapped >> net.sourceforge.jwebunit.exception.UnexpectedJavascriptConfirmException: A >> unexpected confirm with message [You are about to remove BrandService(s) >> from this site. Continue?] was displayed (script in >> http://localhost:8080/edit-site.html?id=1 from (471, 32) to (668, >> 10)#532) >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:528) >> >> at org.mozilla.javascript.Context.call(Context.java:502) >> at >> org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:437) >> >> at >> com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:917) >> >> at >> com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeEventHandler(EventListenersContainer.java:143) >> >> at >> com.gargoylesoftware.htmlunit.javascript.host.EventListenersContainer.executeBubblingListeners(EventListenersContainer.java:156) >> >> at >> com.gargoylesoftware.htmlunit.javascript.host.Node.fireEvent(Node.java:550) >> at >> com.gargoylesoftware.htmlunit.html.HtmlElement$2.run(HtmlElement.java:1251) >> at org.mozilla.javascript.Context.call(Context.java:502) >> at >> org.mozilla.javascript.ContextFactory.call(ContextFactory.java:511) >> at >> com.gargoylesoftware.htmlunit.html.HtmlElement.fireEvent(HtmlElement.java:1255) >> >> at >> com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:136) >> >> at >> com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:107) >> >> at >> com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:76) >> >> at >> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.clickButtonWithText(HtmlUnitTestingEngineImpl.java:1884) >> >> ... 27 more >> Caused by: org.mozilla.javascript.WrappedException: Wrapped >> net.sourceforge.jwebunit.exception.UnexpectedJavascriptConfirmException: A >> unexpected confirm with message [You are about to remove BrandService(s) >> from this site. Continue?] was displayed (script in >> http://localhost:8080/edit-site.html?id=1 from (471, 32) to (668, >> 10)#532) >> at >> org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1657) >> at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:176) >> at >> org.mozilla.javascript.FunctionObject.call(FunctionObject.java:478) >> at >> org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3335) >> at >> org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2484) >> at >> org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:164) >> >> at >> org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:401) >> at >> com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:170) >> >> at >> org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3004) >> at >> org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:162) >> >> at >> com.gargoylesoftware.htmlunit.javascript.host.EventHandler.call(EventHandler.java:78) >> >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:465) >> >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$6.doRun(JavaScriptEngine.java:430) >> >> at >> com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:522) >> >> ... 42 more >> Caused by: >> net.sourceforge.jwebunit.exception.UnexpectedJavascriptConfirmException: A >> unexpected confirm with message [You are about to remove BrandService(s) >> from this site. Continue?] was displayed >> at >> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl$3.handleConfirm(HtmlUnitTestingEngineImpl.java:830) >> >> at >> com.gargoylesoftware.htmlunit.javascript.host.Window.jsxFunction_confirm(Window.java:168) >> >> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) >> at >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) >> >> at >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) >> >> at java.lang.reflect.Method.invoke(Method.java:597) >> at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:161) >> ... 54 more >> >> >> Thanks, >> Emerson >> >> >> >> >> Check me out! <http://www.myspace.com/emersonsanchez> >> ------------------------------ >> Get your new Email address! >> <http://sg.rd.yahoo.com/aa/mail/domainchoice/mail/signature/*http://mail.promotions.yahoo.com/newdomains/aa/> >> Grab the Email name you've always wanted before someone else does! >> >> ------------------------------------------------------------------------------ >> This SF.Net email is sponsored by the Verizon Developer Community >> Take advantage of Verizon's best-in-class app development support >> A streamlined, 14 day to market process makes app distribution fast and >> easy >> Join now and get one step closer to millions of Verizon customers >> http://p.sf.net/sfu/verizon-dev2dev >> _______________________________________________ >> JWebUnit-users mailing list >> JWebUnit-users@lists.sourceforge.net<http://mc/compose?to=jwebunit-us...@lists.sourceforge.net> >> https://lists.sourceforge.net/lists/listinfo/jwebunit-users >> >> > > -----Inline Attachment Follows----- > > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and > easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > > -----Inline Attachment Follows----- > > > _______________________________________________ > JWebUnit-users mailing list > JWebUnit-users@lists.sourceforge.net<http://mc/compose?to=jwebunit-us...@lists.sourceforge.net> > https://lists.sourceforge.net/lists/listinfo/jwebunit-users > > > ------------------------------ > Get your preferred Email name! > <http://sg.rd.yahoo.com/aa/mail/domainchoice/mail/signature/*http://mail.promotions.yahoo.com/newdomains/aa/> > Now you can @ymail.com and @rocketmail.com. > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and > easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > JWebUnit-users mailing list > JWebUnit-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jwebunit-users > >
------------------------------------------------------------------------------ This SF.Net email is sponsored by the Verizon Developer Community Take advantage of Verizon's best-in-class app development support A streamlined, 14 day to market process makes app distribution fast and easy Join now and get one step closer to millions of Verizon customers http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________ JWebUnit-users mailing list JWebUnit-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-users