I understand that PhantomJS is a [headless browser][1]. And I get that you can use drivers such as webdriver.io to talk to the headless browser.
But then why does PhantomJS have its own objects like page, etc. so you can essentially do the same as a driver, send requests to open pages on the browser?
My question: So then if I'm right, does it really come down to a choice whether you either use Phantom's native objects to talk to its own headless browser (Webkit) or another driver like the Selenium Webdriver?
Just trying to understand my options. Like if I should even worry about using Phantom's own objects other than use it to start up and use something else to talk to it...because I started down the path of trying to use Phantom's createPage but hit a wall when I tried using it in Cucumber.js tests because I lost scope of Cucumber when trying to wrap my cucumber step definitions inside the createPage function...
for example, I can't get this to work so figured maybe I should just use Zombie.js or webkit.io to talk to Phantom instead since I have such a headache right now with my code below. I don't know maybe there's a simple solution that I don't see in my code:
var phantom = require('phantom'), _ph, _page;
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;
console.log("_page: " + _page);
_page.onLoadFinished = function(status) {
console.log("Page Loaded: " + status);
};
//_ph.exit();
});
});
module.exports = function() {
"use strict";
this.Given(/^I visit the episodes display page$/, function (callback) {
console.log("got here, _page: " + _page);
_page.open("/", function(status){
status.should.equal("success");
});
_ph.exit();
callback();
});
this.Then(/^I should not see any customers listed$/, function (callback) {
// not implemented
callback.pending();
});
this.Given(/^there are some customers to view$/, function (callback) {
// not implemented
callback.pending();
});
this.When(/^I go to the customers display page$/, function (callback) {
// not implemented
callback.pending();
});
this.Then(/^I should see a list of customers grouped by Topic$/, function (callback) {
// not implemented
callback.pending();
});
};
[1]: http://ift.tt/1jHB2OE
Aucun commentaire:
Enregistrer un commentaire