On Wed, Oct 29, 2008 at 2:14 AM, Julien HENRY <[EMAIL PROTECTED]> wrote: > Try something like: > > protected String getInsertedUserId() { > beginAt("/users.html"); > assertTablePresent("userList"); > assertTextInTable("userList", "Spring"); > Table table = getTable("userList"); > return ((Row) table.getRows().get(table.getRowCount()-1)).getCell(0); > }
Thanks, the following seems to work: protected String getInsertedUserId() { beginAt("/users.html"); assertTablePresent("userList"); assertTextInTable("userList", "Spring"); Table table = getTable("userList"); Cell cell = (Cell) ((Row) table.getRows().get(table.getRowCount()-1)).getCells().get(0); return cell.getValue(); } Matt > > ----- Message d'origine ---- > De : Matt Raible <[EMAIL PROTECTED]> > À : Usage problems for JWebUnit <jwebunit-users@lists.sourceforge.net> > Envoyé le : Mardi, 28 Octobre 2008, 22h56mn 20s > Objet : Re: [JWebUnit-users] Re : Re : Re : Upgrading from 1.2 to 2.0 > > I'll submit an issue to HtmlUnit. > > Using setScriptingEnabled(false) worked. > > Any ideas how to make the following work with 2.0? > > /** > * Convenience method to get the id of the inserted user > * Assumes last inserted user is "Spring User" > * @return last id in the table > */ > protected String getInsertedUserId() { > beginAt("/users.html"); > assertTablePresent("userList"); > assertTextInTable("userList", "Spring"); > String[][] tableCellValues = > getDialog().getSparseTableBySummaryOrId("userList"); > return tableCellValues[tableCellValues.length-1][0]; > } > > Thanks, > > Matt > > On Tue, Oct 28, 2008 at 3:12 PM, Julien HENRY <[EMAIL PROTECTED]> wrote: >> This is a JavaScript exception. HtmlUnit support of JS is not perfect. >> >> You should submit a JS bug to HtmlUnit guys: >> http://htmlunit.sourceforge.net/submittingJSBugs.html >> >> To disable JavaScript, the good solution is to call >> setScriptingEnabled(false). But if your site require JavaScript, it will not >> help to test it. >> >> Regards, >> >> Julien >> >> >> >> ----- Message d'origine ---- >> De : Matt Raible <[EMAIL PROTECTED]> >> À : Usage problems for JWebUnit <jwebunit-users@lists.sourceforge.net> >> Envoyé le : Mardi, 28 Octobre 2008, 18h45mn 17s >> Objet : Re: [JWebUnit-users] Re : Re : Upgrading from 1.2 to 2.0 >> >> OK, I've done that and it appears that things are working better. Now >> I'm seeing the following issue: >> >> https://sourceforge.net/tracker/?func=detail&atid=497982&aid=1958470&group_id=61302 >> >> ======= EXCEPTION START ======== >> EcmaError: lineNumber=[9] column=[0] lineSource=[<no source>] >> name=[TypeError] >> sourceName=[http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js] >> message=[TypeError: Cannot call method "indexOf" of null >> (http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js#9)] >> com.gargoylesoftware.htmlunit.ScriptException: TypeError: Cannot call >> method "indexOf" of null >> (http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.3/prototype.js#9) >> 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) >> >> I tried adding an exclusion to disable JavaScript. >> >> <exclusions> >> <exclusion> >> <groupId>net.sourceforge.htmlunit</groupId> >> <artifactId>htmlunit-core-js</artifactId> >> </exclusion> >> </exclusions> >> >> But that results in: >> >> java.lang.NoClassDefFoundError: org/mozilla/javascript/EvaluatorException >> at >> com.gargoylesoftware.htmlunit.WebWindowImpl.<init>(WebWindowImpl.java:39) >> at >> com.gargoylesoftware.htmlunit.TopLevelWindow.<init>(TopLevelWindow.java:40) >> at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:209) >> at >> net.sourceforge.jwebunit.htmlunit.HtmlUnitTestingEngineImpl.initWebClient(HtmlUnitTestingEngineImpl.java:721) >> >> Thanks, >> >> Matt >> >> On Tue, Oct 28, 2008 at 10:18 AM, Julien HENRY <[EMAIL PROTECTED]> wrote: >>> Sorry, >>> >>> Move everything from your constructor to the setUp method... >>> >>> >>> >>> ----- Message d'origine ---- >>> De : Matt Raible <[EMAIL PROTECTED]> >>> À : Usage problems for JWebUnit <jwebunit-users@lists.sourceforge.net> >>> Envoyé le : Mardi, 28 Octobre 2008, 17h16mn 28s >>> Objet : Re: [JWebUnit-users] Re : Upgrading from 1.2 to 2.0 >>> >>> I get another error after making this change: >>> >>> junit.framework.AssertionFailedError: Exception in constructor: >>> testWelcomePage (java.lang.NullPointerException >>> at >>> net.sourceforge.jwebunit.junit.WebTestCase.getTestContext(WebTestCase.java:106) >>> at org.appfuse.web.UserWebTest.<init>(UserWebTest.java:15) >>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) >>> >>> <code> >>> import net.sourceforge.jwebunit.junit.WebTestCase; >>> import net.sourceforge.jwebunit.util.TestingEngineRegistry; >>> >>> import java.util.ResourceBundle; >>> >>> public class UserWebTest extends WebTestCase { >>> private ResourceBundle messages; >>> >>> public UserWebTest(String name) { >>> super(name); >>> getTestContext().setBaseUrl("http://localhost:25888"); >>> getTestContext().setResourceBundleName("messages"); >>> messages = ResourceBundle.getBundle("messages"); >>> //getTestContext().setLocale(Locale.GERMAN); >>> //getTestContext().getWebClient().setHeaderField("Accept-Language", >>> "de"); >>> } >>> >>> public void setUp() { >>> setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); >>> } >>> >>> public void testWelcomePage() { >>> beginAt("/"); >>> assertTitleKeyMatches("index.title"); >>> } >>> } >>> </code> >>> >>> On Tue, Oct 28, 2008 at 8:01 AM, Julien HENRY <[EMAIL PROTECTED]> wrote: >>>> Hi Matt, >>>> >>>> Move >>>> setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); >>>> from the constructor to the setUp() method... >>>> and open a bug (at least the doc on the web site should be updated). >>>> >>>> Regards, >>>> >>>> Julien >>>> >>>> >>>> >>>> >>>> >>>> ----- Message d'origine ---- >>>> De : Matt Raible <[EMAIL PROTECTED]> >>>> À : jwebunit-users@lists.sourceforge.net >>>> Envoyé le : Mardi, 28 Octobre 2008, 9h25mn 15s >>>> Objet : [JWebUnit-users] Upgrading from 1.2 to 2.0 >>>> >>>> I'm trying to upgrade from an older version of jWebUnit to the latest >>>> and greatest that uses HtmlUnit. However, I keep getting the following >>>> error in my test output (from Maven). >>>> >>>> Tests run: 5, Failures: 5, Errors: 0, Skipped: 0, Time elapsed: 0.054 >>>> sec <<< FAILURE! >>>> warning(junit.framework.TestSuite$1) Time elapsed: 0.006 sec <<< FAILURE! >>>> junit.framework.AssertionFailedError: Exception in constructor: >>>> testWelcomePage (java.lang.NullPointerException >>>> at >>>> net.sourceforge.jwebunit.junit.WebTestCase.setTestingEngineKey(WebTestCase.java:2032) >>>> at org.appfuse.web.UserWebTest.<init>(UserWebTest.java:15) >>>> at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) >>>> at >>>> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39) >>>> at >>>> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27) >>>> at java.lang.reflect.Constructor.newInstance(Constructor.java:494) >>>> at junit.framework.TestSuite.createTest(TestSuite.java:65) >>>> at junit.framework.TestSuite.addTestMethod(TestSuite.java:283) >>>> at junit.framework.TestSuite.<init>(TestSuite.java:146) >>>> at >>>> org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:69) >>>> >>>> The relevant code in my class is as follows: >>>> >>>> import net.sourceforge.jwebunit.junit.WebTestCase; >>>> import net.sourceforge.jwebunit.util.TestingEngineRegistry; >>>> >>>> >>>> import java.util.ResourceBundle; >>>> >>>> public class UserWebTest extends WebTestCase { >>>> private ResourceBundle messages; >>>> >>>> public UserWebTest(String name) { >>>> super(name); >>>> setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); >>>> getTestContext().setBaseUrl("http://localhost:25888"); >>>> getTestContext().setResourceBundleName("messages"); >>>> messages = ResourceBundle.getBundle("messages"); >>>> //getTestContext().setLocale(Locale.GERMAN); >>>> //getTestContext().getWebClient().setHeaderField("Accept-Language", >>>> "de"); >>>> } >>>> >>>> public void testWelcomePage() { >>>> beginAt("/"); >>>> assertTitleKeyMatches("index.title"); >>>> } >>>> >>>> The error seems to be occurring at the following line: >>>> >>>> setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT); >>>> >>>> If I remove this line, the error is: >>>> >>>> junit.framework.AssertionFailedError: Exception in constructor: >>>> testWelcomePage (java.lang.NullPointerException >>>> at >>>> net.sourceforge.jwebunit.junit.WebTestCase.getTestContext(WebTestCase.java:106) >>>> at org.appfuse.web.UserWebTest.<init>(UserWebTest.java:15) >>>> >>>> I'm using Java 5 and Maven 2.0.9 on OS X. >>>> >>>> Thanks, >>>> >>>> Matt >>>> >>>> ------------------------------------------------------------------------- >>>> This SF.Net email is sponsored by the Moblin Your Move Developer's >>>> challenge >>>> Build the coolest Linux based applications with Moblin SDK & win great >>>> prizes >>>> Grand prize is a trip for two to an Open Source event anywhere in the world >>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>>> _______________________________________________ >>>> 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 Moblin Your Move Developer's >>>> challenge >>>> Build the coolest Linux based applications with Moblin SDK & win great >>>> prizes >>>> Grand prize is a trip for two to an Open Source event anywhere in the world >>>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>>> _______________________________________________ >>>> 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 Moblin Your Move Developer's challenge >>> Build the coolest Linux based applications with Moblin SDK & win great >>> prizes >>> Grand prize is a trip for two to an Open Source event anywhere in the world >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>> _______________________________________________ >>> 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 Moblin Your Move Developer's challenge >>> Build the coolest Linux based applications with Moblin SDK & win great >>> prizes >>> Grand prize is a trip for two to an Open Source event anywhere in the world >>> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >>> _______________________________________________ >>> 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 Moblin Your Move Developer's challenge >> Build the coolest Linux based applications with Moblin SDK & win great prizes >> Grand prize is a trip for two to an Open Source event anywhere in the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> 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 Moblin Your Move Developer's challenge >> Build the coolest Linux based applications with Moblin SDK & win great prizes >> Grand prize is a trip for two to an Open Source event anywhere in the world >> http://moblin-contest.org/redirect.php?banner_id=100&url=/ >> _______________________________________________ >> 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 Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > 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 Moblin Your Move Developer's challenge > Build the coolest Linux based applications with Moblin SDK & win great prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > 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 Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ JWebUnit-users mailing list JWebUnit-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jwebunit-users