Permalink
Browse files

Fixing an issue in the way Element were fetched.

In case an Element is fetched using "executeScript", we need to check that Element exists in the page.
If it does, let it continue: we are in the safe.
  • Loading branch information...
1 parent dec51bb commit 0b1bfbaad16a93d94df7f54faeedd66c970f38e2 @detro committed Jun 4, 2012
@@ -47,6 +47,8 @@ ghostdriver.WebElementReqHand = function(id, session) {
_handle = function(req, res) {
_protoParent.handle.call(this, req, res);
+ // console.log("Request => " + JSON.stringify(req, null, ' '));
+
// TODO lots to do...
if (req.urlParsed.file === _const.VALUE && req.method === "POST") {

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -1,4 +1,4 @@
-2012-06-04 13:16:48
+2012-06-04 15:27:52
------------------------------------------------------------------------
r17108 | jmleyba | 2012-06-04 05:06:09 +0200 (Mon, 04 Jun 2012) | 1 line
View
@@ -81,8 +81,22 @@ ghostdriver.WebElementLocator = function(session) {
},
_getElement = function(id) {
+ var el;
+
if (typeof(_elements[id]) !== "undefined") {
+ // If element was previously "found"
return _elements[id];
+ } else {
+ // Check if the object exists in the page
+ el = _session.getCurrentWindow().evaluate(
+ require("./webdriver_atoms.js").get("get_element_from_cache"),
+ id);
+
+ if (typeof(el) === "object") {
+ // The object exists: we are in the safe
+ _elements[id] = new ghostdriver.WebElementReqHand(id, _session);
+ return _elements[id];
+ }
}
return null;
};
@@ -10,10 +10,16 @@ js_fragment(name = "forward",
function = "bot.window.forward",
deps = [ "//javascript/atoms:deps" ])
+js_fragment(name = "get_element_from_cache",
+ module = "bot.inject.cache",
+ function = "bot.inject.cache.getElement",
+ deps = [ "//javascript/atoms:deps" ])
+
js_deps(name = "build_atoms",
deps = [
":back",
":forward",
+ ":get_element_from_cache",
"//javascript/webdriver/atoms:execute_script",
"//javascript/webdriver/atoms:execute_async_script",
View
@@ -32,6 +32,9 @@ pushd $SELENIUM_REPO_PATH
# Build all the Atoms
./go //javascript/$TEMP_BUILD_DIR_NAME:$ATOMS_BUILD_TARGET
+# Before importing, delete the previous atoms
+rm $DESTINATION_DIRECTORY/*
+
# Import only the Atoms JavaScript files
JS_LIST="./build/javascript/webdriver/atoms/*.js ./build/javascript/webdriver/atoms/inject/*.js ./build/javascript/phantomjs-driver/*.js"
for JS in $JS_LIST

0 comments on commit 0b1bfba

Please sign in to comment.