How can I tell Selenium Webdriver on Firefox Quantum to use a proxy with auth and port? - node.js

I have tried pretty much every way mentioned on SO and the docs and failed.
Specifically, I'm using WebdriverJS through Node.js.
I'd want a way to programatically make Firefox-Quantum use a proxy, which requires auth and port (i.e http://user:pass#host:port).
I don't mind to use an extension for this, but I don't know which one I could use for programmatic access.
I do not want a solution involving the authentication dialog popping up and asking for the auth.
I used to manage to do it on Firefox 56.0 using an extension called CloseProxy. (As per How to set proxy authentication (user & password) using python selenium)
However, CloseProxy is not supported on Firefox-Quantum.
This is my last attempt at this issue before resorting to going ahead and writing my own Webextension for this so I hope someone somewhere has the answer

Somethig like that should work:
var webdriver = require('selenium-webdriver'),
proxy = require('selenium-webdriver/proxy');
var driver = new webdriver.Builder()
.withCapabilities(webdriver.Capabilities.firefox())
.setProxy(proxy.manual({http: 'host:1234'}))
.build();
Actually there is a lot of info about this https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/proxy.html

Related

How to use and access the preference in thunderbird , in Webextension environment ,not in the legacy

Currently using this method as a legacy method.
this.prefService = Components
.classes["#mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
this.prefBranch = this.prefService.getBranch(root);
but i did not get a complete idea about how to use this in the webextension environment thunderbird .any api in order to use this feature ?
I solved my issue, by using Web Extension experiment.
Implemented the same legacy extension function with the Web Extension Experiment Specification and that solved my need at this moment.
the link mentioned below.
https://thunderbird-webextensions.readthedocs.io/en/68/how-to/experiments.html
https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/functions.html
I think you can use the storage.local API (see documentation, it seems to work the same for Firefox and Thunderbird). This allows you to store data related to your add-on with something like:
let settingItem = browser.storage.local.set(
keys // object
)
and to retrieve or remove it after that (see available methods).

How to use the ChromeApp to connect to a node.js server?

I have a Node.js server and I'd like to know how I could do for the ChromeApp to work with it. I tried putting "http://localhost:3000" (server address) on the runtime:
chrome.app.runtime.onLaunched.addListener(function () {
chrome.app.window.create('http://localhost:3000');
});
But it doesn't even launch. Does someone have an idea on what I could do?
Thanks.
You cannot launch external URLs with chrome.app.window.create. In fact if you check the chrome.runtime.lastError property you will see the following error:
The URL used for window creation must be local for security reasons.
I suggest you look into using the <webview> tag as it is much more appropriate for your use-case.

WebGL local textures and cross-domain

I wrote a webgl program which works well with a local server, and now, I would like to run it locally.
But I had errors and after some researches, I found that it's a cross domain issue in loading textures.
function loadTexture( path ) {
var texture = new THREE.Texture( texture_placeholder );
var material = new THREE.MeshBasicMaterial( { map: texture, overdraw: true} );
var image = new Image();
image.onload = function () {
texture.needsUpdate = true;
material.map.image = this;
render();
};
texture.deallocate();
renderer3D.deallocateTexture( texture );
return material;
}
I tried several solutions :
github.com/mrdoob/three.js/issues/1305
github.com/mrdoob/three.js/issues/944
gist.github.com/ekeneijeoma/1186920
github.com/mrdoob/three.js/wiki/How-to-run-things-locally (the 1.Change security for local files in a browser (access page as file:///example))
I precise that I have no problem on Firefox, it works without changing anything.
The only solution which works on Chrome is to launch it with --allow-file-access-from-files.
And on IE, I don't know how to solve it, I enabled in the browser security options "Access data sources across domains" and "Navigate sub-frames across different domains" (http://msdn.microsoft.com/fr-fr/library/ee797612(v=cs.20).aspx) but nothing. I use IEWebGL and I have noticed that on http://iewebgl.com/, "IEWebGL v1.0 Released" section, it's written "- Secure (no local content loading, no cross-domain textures)". So maybe it can't be solved on IE due to IEWebGL !?
So what would be the solution for IE, if there is one? And is there a way to solve the problem by changing the code, without lauching a local server or Chrome with special option?
Thanks!
this question has been asked and answered at least 6 other times and is even answered in the three.js wiki.
The short of it is you need to run a local server. Open a terminal/shell/command prompt and type
cd <path/to/files>
python -m SimpleHTTPServer
Then in your browser go to
http://localhost:8000
Why is that not an option? It's simple and it solves the problem. It also doesn't leave your browser open to getting owned.
Here's several simple servers you could use
thanks for your answer.
Indeed, it has already been asked and solved, I saw the solutions and it works well with a local server, and I totally agree with about security.
I was asking that because, firstly, it works without any server on Firefox and Safari, and on Google with --allow..., so if it was possible on IE, it would have been good. And secondly, because I wanted a very simple program which works quickly without having to install python or something else for a server,...
In fact, it's for an offline application (I know it's weird for a web based application but it's not my choice :) ). Anyway, it works for Firefox, Chrome and Safari so, too bad for IE.
Thanks!

cherrypy.session won't work on Chrome but works on Firefox

I run a web with CherryPy (version 3.2.0) and use cherrypy.session to store session specific data. It works perfectly with Firefox. However, I noticed that cherrypy.session would run in problems on Chrome. Basically, it looks like session variable resets when the consequent pages are being browsed.
I believe my config is set correctly
tools.sessions.on = True
tools.sessions.storage_type = "ram"
tools.sessions.storage_path = "/home/dmitry/test/sessions"
tools.sessions.timeout = 60
tools.sessions.name = "test"
What can lead to such a browser-specific problem?
I guess by now you've figured out the solution, but one possible cause can be that the development server is running on localhost, and chrome refuses to set cookies. You have to set up exceptions to make it work. Searching Google for this issue brings up some promising results.

Output to Chrome console from Node.js

I'm looking for a way to output Node variables directly into the google chrome browser console. The same way a console.log() works on the client side. Something like this for php. This would greatly speed up development.
NOTE:
Since the old answer (written in september 2014) refers to an older version of node-inspector, my instructions are not relevant anymore in 2017. Also, the documentation has gotten a lot better, so I have updated my original answer:
node-inspector is what you need.
It opens up an instance of Chrome with its developer tools for debugging.
It's also easy to use:
1. Install
$ npm install -g node-inspector
2. Start
$ node-debug app.js
Source: https://github.com/node-inspector/node-inspector
You might want to try NodeMonkey - https://github.com/jwarkentin/node-monkey
I know it's an old question but came on top of my Google search so maybe somebody will find my answer useful.
So you can use node --inspect-brk index.js
Now, all you have to do is basically just type chrome://inspect in your Chrome address bar and click Open dedicated DevTools for Node
In DevTools, now connected to Node, you’ll have all the Chrome DevTools features you’re used to:
Complete breakpoint debugging, stepping w/ blackboxing
Source maps for transpiled code
LiveEdit: JavaScript hot-swap evaluation w/ V8
Console evaluation with ES6 feature/object support and custom object formatting
Sampling JavaScript profiler w/ flamechart
Heap snapshot inspection, heap allocation timeline, allocation profiling
Asynchronous stacks for native promises
Hope that helped.
The closest thing to this I've seen is Node JS console object debug inspector
See this post for usage and potential issues: http://thomashunter.name/blog/nodejs-console-object-debug-inspector/
For users with nodejs on linux via ssh-shell (putty):
Problem with nodejs on linux-ssh-shell is, that you have no browser connected.
I tried all this solutions, but didnt get it to work.
So i worked out a solution with firebase (https://firebase.google.com), because my project uses firebase.
If you are familiar with firebase, than this is a great way. If not, firebase is worth using in combination with nodejs - and its free!
In the server-side-script (started with node) use a own function log():
// server-side:
// using new firebase v3 !
var fbRootRef = firebase.database();
var fbConsoleRef = fbRootRef.ref("/console");
var log = function(args) {
fbConsoleRef.set({'obj': args});
}
// inside your server-code:
log({'key':'value'});
On client-side you create a firebase-reference on this console-object:
// client side:
fbRootRef.child('/console').on('value', function(d) {
var v = d.val();
console.log(v);
});
Now everything logged on server-side with the log() - function is transferred in realtime to the firebase-database and from there triggering the client-console-reference and logged into the browsers console.
If anyone needs help, i will explain in more detail and could give a more extended version of this logging with types (console./log/warn/info), grouping with title-info (i.e. server says: (filename + line).
Setting up firebase for your project is done in max 30 minutes, inserting the console-function in 30 minutes. I think its worth the time!
You can use bonsole, a simple way to log something in browser. Even in Linux, you can go to the LAN's ip to check it.
The most simple way with least dependencies is using a WebSocket connection to send the messages to the browser. Any WebSocket example you can find on the internet will suffice to accomplish this. Everything else requires to be heavily integrated into the host system and wouldn't work if you want to actually run this on a remote server. You can also send commands to the server directly from the browser console this way.
Links:
https://www.npmjs.com/package/websocket
https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_client_applications

Resources