i've got dumb question - how to run scripts located on tested site? I can run alert, but i dont have access to scripts written by my. I've tried runscript, geteval - without any effect.
Since Selenium is written in JavaScript the window object moves to within the Selenium object.
What you need to do is
selenium.get_eval("this.browserbot.getUserWindow().youScriptOnThePage")
Related
I am looking for a way to run individual commands in VS Code but not the whole file. I do work on client websites where a lot of my code will not run in a standard debugger or in the Quokka extension because it relies on the page that I am working on (and running in the debugger does not perfectly emulate how my code will run. But sometimes I like to run a few lines of code or a single function separately to make sure I have it set right without having to copy my code over to the online platform used to execute it and load up a preview link. Normally what I like to do is open a new chrome tab at about:blank and use the dev console there to paste in my code and this is my "playground" of sorts. Is there any form of active JS engine that I can do this in without having to save these lines to a new file and run the debugger?
If you looking all these things in VS code I think it will be a bit hard because of this.
to run JS code snippet VS code must have JS engine like same for PHP its compiler or same for any other language and adding these compilers in IED will again make these IEDs fat and CPU costly.
BUT Still, you can do one thing if you have a node js installed open Terminal outside or inside the VS code.
and type
$node
This will open a JS playground. Where you can execute js code snippets
but here you will not be able to access DOM, WINDOW object, etc.
In case you found any plugin which executes js code in VS CODE with DOM, window please let me know.
Let say I want to see what is the value of this code, I want to run it. Can I select it and run that, and it would automatically import and execute all dependencies etc.
VS Code is an editor, not a full IDE.
By itself, it run any code.
If you are writing for node.js, you may be able to call out to node and run things within a terminal window or, with the right plugin, turn on the debugger.
If you are writing code for the browser, then no, you cannot fully run that code inside VS code. You might want to use a tool that will watch for changes and reload the browser window.
I am running a jupyter notebook on a local server and spent the entire last day trying to get a javascript library for charting to run. It's called Dygraph (http://dygraphs.com/). Outside of the jupyter notebook everything is working as it should, but if I want to use the library inside a notebook, then things get messy. Even displaying a simple html file, which uses the library and works just fine outside jupyter, is not working when viewed via the server. All resources are in the right place and seem to get executed, just without having a lasting effect.
I know that the script is executed, because I appended "console.log('okay')" to the local source file (http://dygraphs.com/2.1.0/dygraph.min.js) and "okay" is in fact showing up in the browser console.
I executed the script in the following ways (none of which were effective):
By using IPython to paste a script tag, which links to the resource (src="...")
By reading the content of the script using python and using IPython to execute the javascript directly
The most obvious way: by manually copy-pasting the content of
dygraph.min.js into the console
If I execute 3) on any other site, then I can successfully run the following simple statement:
console.log(Dygraph)
However when I am inside the notebook and try the same, I instead just get:
ReferenceError: Dygraph is not defined
How is this possible and how to fix it?
PS:
I also tried using the python wrapper PyDyGraphs (https://github.com/DayStarEngineering/PyDyGraphs). The example code of the github page throws the same ReferenceError and the graph is not displayed correctly (instead there is just the empty div).
I'm not exactly sure how to phrase my question but I'll give it my best shot.
If I load up a webpage, in the HTML it executes a JavaScript file. And if I view the page source I can see the source of that JavaScript (though it's not very well formatted and hard to understand).
Is there a way to run the JavaScript from e.g. Python code, without going through the browser? i.e if I wanted to access a particular function in that JavaScript, is there a clean way to call just that from a Python script, and read the results?
For example... a webpage displays a number that I want access to. It's not in the page source because it's a result from a JavaScript call. Is there a way to call that JavaScript from Python?
If you want to scrape a page with javascript in it you've got at least two options:
Use selenium to load the page and get the node value you're interested in
Use python-spidermonkey to leverage the javascript right from your python script and get the value you're interested in.
Although your question isn't very clear. I'm guessing that you are trying to access the javascript console.
In Google Chrome:
Press F12
Go to the 'console' tab
In Mozilla Firefox with Firebug installed:
Open Firebug
Go to the 'console' tab
From the console you can execute javascript query's (calling functions, accessing variables etc.).
I hope this answered your question properly.
I think you are talking about Obfuscate js code
You can always de-obfuscate them
There are lots of tools availaible
Here is a addon of mozilla
https://addons.mozilla.org/en-us/firefox/addon/javascript-deobfuscator/
and an online tool
http://jsbeautifier.org/
I'm working with a tool that only allows for Javascript as the scriptting language. With the script, I need to launch a process. How would I go about this?
The javascript code is running on the client that will launch the process. The javascript interpeter is RhinoJS.
So my question remains:
1. Is there a way that I can call a specific Java class from Rhino [ProcessBuilder]?
or
2. Is there a way to launch an executable from Javascript? [I've tried the UniversalXPConnect route, but it turns out that the version of Rhino I'm using doesn't really worry about permissions]
That was quick [I found the answer right after I asked]:
var pb = new java.lang.ProcessBuilder("notepad.exe", "c:\test");
pb.start();
Basically RhinoJS has a quirk to allow it to directly access Java functionality. So basically once should just launch the process from there.