CoffeeManiac you could either use a promises to synchronize your async 
issues 
(https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=q%20promise)
 
or you could move phantom.create down into the module and call _page.open 
inside the _ph.createPage callback (or some abstraction of the same).

On Friday, March 20, 2015 at 10:50:18 AM UTC-4, CoffeeManiac wrote:
>
> Right but I do not know how to resolve this.  How can I get this to work?
>
>
>
> On Thursday, March 19, 2015 at 4:16:37 PM UTC-5, Zach Rollyson wrote:
>>
>> Initial assumption would be that _page gets defined in a callback within 
>> a callback and _page.open gets called in a different callback so all that 
>> is asynchronous and there could be no guarantee that _page is defined by 
>> the time _page.open is called.
>>
>> On Thursday, March 19, 2015 at 4:39:36 PM UTC-4, CoffeeManiac wrote:
>>>
>>> I can't figure out why I lose the object instance for my variable _page 
>>> once it gets inside the function for the module.exports.  It bombs out here 
>>> because _page is undefined but it's fine and has an instance BEFORE this 
>>> _page.open 
>>>
>>> var phantom = require('phantom'), _ph, _page;
>>> var should = require('chai').should();
>>>
>>> phantom.create("--web-security=no", "--ignore-ssl-errors=yes", { port: 
>>> 12345 }, function (ph) {
>>>     console.log("Phantom Bridge Initiated");
>>>     _ph = ph;
>>>
>>>     _ph.createPage(function(page) {
>>>         console.log("Page created!");
>>>         _page = page;
>>>     });
>>>
>>>     phaçntom.exit();
>>> });
>>>
>>>
>>> module.exports = function() {
>>>     "use strict";
>>>
>>>     this.Given(/^I visit the episodes display page$/, function (callback) {
>>>
>>>         console.log("_page: " + _page);
>>>         _page.open("/", function(status){
>>>
>>>             status.should.equal("success");
>>>         });
>>>
>>>         callback();
>>>
>>>     });
>>>
>>>
>>>     this.Then(/^I should not see any episodes listed$/, function (callback) 
>>> {
>>>         //page.should.have.content("There are no episodes available");
>>>
>>>         callback.pending();
>>>     });
>>>
>>>
>>>
>>>     this.Given(/^there are some episodes to view$/, function (callback) {
>>>         // Write code here that turns the phrase above into concrete actions
>>>         callback.pending();
>>>     });
>>>
>>>     this.When(/^I go to the episodes display page$/, function (callback) {
>>>         // Write code here that turns the phrase above into concrete actions
>>>         callback.pending();
>>>     });
>>>
>>>     this.Then(/^I should see a list of episodes grouped by Topic$/, 
>>> function (callback) {
>>>         // Write code here that turns the phrase above into concrete actions
>>>         callback.pending();
>>>     });
>>>
>>>
>>> };
>>>
>>>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/745d505a-f573-4cf4-ad00-86c9c6743089%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to