Closed tdhock closed 9 years ago
in the example above the desired output is a character vector c("parent", "perforamance", "personalbar", "plot", etc.)
Hi Toby,
A refinement of something like the following may work:
library(RSelenium)
RSelenium::startServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("http://www.r-project.org")
'myArray = [];
for(var b in window) {
if(window.hasOwnProperty(b)) {myArray.push(b);}
}
return myArray;' -> myScript
myDOM <- remDr$executeScript(myScript)[[1]]
> myDOM
[1] "close" "stop"
[3] "focus" "blur"
[5] "open" "alert"
[7] "confirm" "prompt"
[9] "print" "showModalDialog"
[11] "postMessage" "captureEvents"
[13] "releaseEvents" "getSelection"
[15] "getComputedStyle" "matchMedia"
[17] "moveTo" "moveBy"
[19] "resizeTo" "resizeBy"
[21] "scroll" "scrollTo"
[23] "scrollBy" "requestAnimationFrame"
[25] "cancelAnimationFrame" "getDefaultComputedStyle"
[27] "mozRequestAnimationFrame" "mozCancelAnimationFrame"
[29] "mozCancelRequestAnimationFrame" "scrollByLines"
[31] "scrollByPages" "sizeToContent"
[33] "updateCommands" "find"
[35] "dump" "setResizable"
[37] "btoa" "atob"
[39] "setTimeout" "clearTimeout"
[41] "setInterval" "clearInterval"
[43] "self" "name"
[45] "history" "locationbar"
[47] "menubar" "personalbar"
[49] "scrollbars" "statusbar"
[51] "toolbar" "status"
[53] "closed" "frames"
[55] "length" "opener"
[57] "parent" "frameElement"
[59] "navigator" "external"
[61] "applicationCache" "screen"
[63] "innerWidth" "innerHeight"
[65] "scrollX" "pageXOffset"
[67] "scrollY" "pageYOffset"
[69] "screenX" "screenY"
[71] "outerWidth" "outerHeight"
[73] "performance" "crypto"
[75] "mozAnimationStartTime" "mozInnerScreenX"
[77] "mozInnerScreenY" "devicePixelRatio"
[79] "scrollMaxX" "scrollMaxY"
[81] "fullScreen" "mozPaintCount"
[83] "onwheel" "ondevicemotion"
[85] "ondeviceorientation" "ondeviceproximity"
[87] "onuserproximity" "ondevicelight"
[89] "content" "console"
[91] "sidebar" "onabort"
[93] "onblur" "onfocus"
[95] "oncanplay" "oncanplaythrough"
[97] "onchange" "onclick"
[99] "oncontextmenu" "ondblclick"
[101] "ondrag" "ondragend"
[103] "ondragenter" "ondragleave"
[105] "ondragover" "ondragstart"
[107] "ondrop" "ondurationchange"
[109] "onemptied" "onended"
[111] "oninput" "oninvalid"
[113] "onkeydown" "onkeypress"
[115] "onkeyup" "onload"
[117] "onloadeddata" "onloadedmetadata"
[119] "onloadstart" "onmousedown"
[121] "onmouseenter" "onmouseleave"
[123] "onmousemove" "onmouseout"
[125] "onmouseover" "onmouseup"
[127] "onpause" "onplay"
[129] "onplaying" "onprogress"
[131] "onratechange" "onreset"
[133] "onscroll" "onseeked"
[135] "onseeking" "onselect"
[137] "onshow" "onstalled"
[139] "onsubmit" "onsuspend"
[141] "ontimeupdate" "onvolumechange"
[143] "onwaiting" "onmozfullscreenchange"
[145] "onmozfullscreenerror" "onmozpointerlockchange"
[147] "onmozpointerlockerror" "indexedDB"
[149] "mozIndexedDB" "onerror"
[151] "onafterprint" "onbeforeprint"
[153] "onbeforeunload" "onhashchange"
[155] "onlanguagechange" "onmessage"
[157] "onoffline" "ononline"
[159] "onpagehide" "onpageshow"
[161] "onpopstate" "onresize"
[163] "onunload" "localStorage"
[165] "sessionStorage" "window"
[167] "document" "location"
[169] "top" "$"
[171] "jQuery" "jQuery111105653633473999238"
[173] "myArray" "InstallTrigger"
>
Thanks a lot. I guess that will do for my purposes.
So for your purposes:
'myArray = [];
for(var b in plot) {
myArray.push(b);
}
return myArray;'
Cant find a suitable webpage to check if this works but that should return a character vector of the members of plot
.
As an example the google homepage has a gadget variables:
library(RSelenium)
RSelenium::startServer()
remDr <- remoteDriver()
remDr$open()
remDr$navigate("http://www.google.com")
'myArray = [];
for(var b in gadgets) {
myArray.push(b)
}
return myArray;' -> myScript
myDOM <- remDr$executeScript(myScript)[[1]]
> myDOM
[1] "json" "util" "config" "rpc"
Firefox + firebug gives you this list under the DOM tab
I would like to test this list of variables after rendering a web page. Is it possible to obtain and manipulate that list in R code?