Is it possible for a single functional test to handle 2 different pages? For example, when I execute the following test:
return this.remote
.get(testPage)
.waitForElementByCssSelector('.alfresco-core-Page.allWidgetsProcessed', 5000)
.elementByCss('#UNIT_TEST_MODEL_FIELD>DIV.control>TEXTAREA')
.type(testData)
.end()
.elementByCss("#LOAD_TEST_BUTTON")
.click()
.sleep(2000)
.waitForElementByCssSelector('.alfresco-core-Page.allWidgetsProcessed', 5000)
.elementByCss("#DD1")
.click()
.end();
I get the following error:
Test main - firstTest - Test1 FAILED on chrome 31.0.1650.57 on LINUX:
Error: Cannot call method 'apply' of undefined
TypeError: Cannot call method 'apply' of undefined at null.<anonymous> (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/lib/util.js:108:10)
at /home/dave/ScratchPad/ShareInternTests/node_modules/intern/lib/wd.js:769:29
at signalListener (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:37 :21)
at signalWaiting (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:28 :4)
at resolve (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:19 2:5)
at signalDeferred (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:81 :15)
at signalListener (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:52 :6)
at signalWaiting (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:28 :4)
at resolve (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:19 2:5)
at signalDeferred (/home/dave/ScratchPad/ShareInternTests/node_modules/intern/node_modules/dojo/Deferred.js:81 :15)
Because of the framework that I'm testing I need to load a "bootstrap" test page which I write the test data into and then POST it to persist a test model into the HTTP session which is then rendered in a resultant page.
However, whilst the first part of the test works fine (I see the test data entered and the next page is submitted, I seem to get the error on the 2nd .waitForElementByCssSelector call. I've tried various permutations but can't get this to work.
If I run a completely second test on the second page then this works fine, but ideally I'd like it all captured within a single test.
Is what I'd like to do possible or do I have to break it into separate tests?
Please try using setImplicitWaitTimeout
and use the elementBy*
methods instead of using waitForElementByCssSelector
. It is more efficient, and should work properly.
A second option is to make sure you call end
before the second waitForElementByCssSelector
call; it looks like there is a defect in the way the waitForElement
methods are called, where the #LOAD_TEST_BUTTON
element is being used as the context for the call but waitForElement
accepts no context.