Skip to content

Commit

Permalink
TODOing around.
Browse files Browse the repository at this point in the history
This is done in preparation of the next phase, to make it clearer where we need to do things before considering them "done and working".
  • Loading branch information
detro committed May 3, 2012
1 parent 5ebbe27 commit f913f25
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 15 deletions.
25 changes: 18 additions & 7 deletions TODO.md
@@ -1,21 +1,32 @@
# Important
# Top Priority

* PhantomJS "res.write()" doesn't set the 'Content-Length' header automatically :(
* Decorate req/res objects OR extend SessionReqHand to better manage "after open is done" scenarios
* Implement all the commands :)
* "/session/:sessionid/element" and "/session/:sessionid/elements" need to be handled into 1 (++gracefulness)
* Typing simulation: I want to use something like [jquery autotype](https://github.com/mmonteleone/jquery.autotype/blob/master/jquery.autotype.js)


# Mid Priority

* Support for Proxying
* Support for Screenshots
* Proper Capabilities negotiation
* Subclass "RemoteWebDriver" to make setup via simple API
* Add support for Frames and IFrames in PhantomJS
* And than add it to the driver
* I need to inject something like jQuery in the target webpages (or use the WebDriver JS code already available on the Selenium Repository)


# Low Priority

* Subclass "RemoteWebDriver" to make setup via simple API
* Refactor all the Erros in "error.js" to allow an optional, custom Error Handling.
* This will help to comply with [Wire Protocol Error Handling](http://code.google.com/p/selenium/wiki/JsonWireProtocol#Error_Handling)
* See "error.js/InvalidCommandMethod"
* Add another kind of "Error", like "CommandFailed", that have a different error handling and report
* See [Wire Protocol Failed Commands Error Handling](http://code.google.com/p/selenium/wiki/JsonWireProtocol#Failed_Commands)
* More complex examples


# Things to add to PhantomJS

* Ability to read informations like Operating System, Architecture and so forth
* Ability to handle "alert(), confirm() and prompt()"
* PhantomJS "res.write()" doesn't set the 'Content-Length' header automatically :(
* Add support for Frames and IFrames in PhantomJS
* And than add it to the driver
11 changes: 6 additions & 5 deletions src/request_handlers/session_manager_request_handler.js
Expand Up @@ -56,14 +56,13 @@ ghostdriver.SessionManagerReqHand = function() {
},

_createAndRedirectToNewSessionCommand = function(req, res) {
var desiredCapabilities,
var desiredCapabilities = req.post || {},
newSession;

if (typeof(req.post) === "object") {
desiredCapabilities = req.post;
} else {
desiredCapabilities = JSON.parse(req.post);
if (typeof(desiredCapabilities) !== "object") {
desiredCapabilities = JSON.parse(desiredCapabilities);
}

// Create and store a new Session
newSession = new ghostdriver.Session(desiredCapabilities);
_sessions[newSession.getId()] = newSession;
Expand All @@ -72,6 +71,8 @@ ghostdriver.SessionManagerReqHand = function() {
res.statusCode = 303; //< "303 See Other"
res.setHeader("Location", "/session/"+newSession.getId());
res.closeGracefully();

// TODO Capabilities not provided - Handle error case
},

_listActiveSessionsCommand = function(req, res) {
Expand Down
8 changes: 6 additions & 2 deletions src/request_handlers/session_request_handler.js
Expand Up @@ -36,6 +36,7 @@ ghostdriver.SessionReqHand = function(session) {
_const = {
URL : "url",
ELEMENT : "element",
ELEMENTS : "elements",
ELEMENT_DIR : "/element/",
TITLE : "title",
WINDOW : "window",
Expand Down Expand Up @@ -75,6 +76,7 @@ ghostdriver.SessionReqHand = function(session) {
// Open the given URL and, when done, return "HTTP 200 OK"
_session.getCurrentWindow().open(postObj.url, function(status) {
if (status === "success") {
// TODO Handle situation where loading doesn't work
res.statusCode = 200;
res.closeGracefully();
} else {
Expand Down Expand Up @@ -111,10 +113,10 @@ ghostdriver.SessionReqHand = function(session) {
throw new ghostdriver.VariableResourceNotFound(req);
}
return;
} else if (req.urlParsed.file === _const.FORWARD) {
} else if (req.urlParsed.file === _const.FORWARD && req.method === "POST") {
responseAfterLoadFinished(require("./webdriver_atoms.js").get("forward"));
return;
} else if (req.urlParsed.file === _const.BACK) {
} else if (req.urlParsed.file === _const.BACK && req.method === "POST") {
responseAfterLoadFinished(require("./webdriver_atoms.js").get("back"));
return;
}
Expand All @@ -123,13 +125,15 @@ ghostdriver.SessionReqHand = function(session) {
},

_windowCloseCommand = function(req, res) {
// TODO An optional JSON parameter "name" might be given
_session.closeCurrentWindow();
res.statusCode = 200;
res.closeGracefully();
},

_windowChangeFocusToCommand = function(req, res) {
// TODO
// TODO An optional JSON parameter "name" might be given
},

_titleCommand = function(req, res) {
Expand Down
2 changes: 1 addition & 1 deletion src/request_handlers/status_request_handler.js
Expand Up @@ -31,7 +31,7 @@ ghostdriver.StatusReqHand = function() {
// private:
var
_protoParent = ghostdriver.StatusReqHand.prototype,
_statusObj = {
_statusObj = { //< TODO Report real status
"build" : {
"version" : "0.1a",
"revision" : "none",
Expand Down
3 changes: 3 additions & 0 deletions src/webelementlocator.js
Expand Up @@ -63,6 +63,8 @@ ghostdriver.WebElementLocator = function(session) {
// Use Atom "find_result" to search for element in the page
findElementRes = _session.getCurrentWindow().evaluate(findElementAtom, locator.using, locator.value);

// TODO Handle Missing Elements and XPath errors

// De-serialise the result of the Atom execution
try {
findElementRes = JSON.parse(findElementRes);
Expand All @@ -76,6 +78,7 @@ ghostdriver.WebElementLocator = function(session) {
elementId = findElementRes.value["ELEMENT"];
// Create and Store a new WebElement if it doesn't exist yet
if (typeof(_elements[elementId]) === "undefined") {
// TODO There is no need to store elements here and have them wrapped in WebElementReqHand
_elements[elementId] = new ghostdriver.WebElementReqHand(elementId, _session);
}
return _elements[elementId];
Expand Down

0 comments on commit f913f25

Please sign in to comment.