Start chrome & firefox with proxy using webdriverio in nodejs - node.js

How can I open a browser session with proxy set through the options(/desired capabilities) using WebDriverIO in NodeJs. I use this code for setting proxy, but it stopped working. The browser opens without the proxy and will not perform any further actions.
options = {
desiredCapabilities: {
browserName: 'firefox',
proxy: {
proxyType: 'manual',
httpProxy: '127.0.0.11:80'
}
}
};
client = webdriverio.remote(options).init();

I believe this code should work:
var webdriverio = require('webdriverio');
var options = {
desiredCapabilities: {
browserName: 'firefox'
, proxy: {
proxyType: 'MANUAL'
, httpProxy: '127.0.0.11:80'
}
}
};
client = webdriverio.remote(options).init();
Reference: https://github.com/webdriverio/webdriverio/issues/324

Related

Vue 2 Socket IO on VM URL replaced by http%22http

My socket IO URL is replaced by weird string like http://%22 on my VM (Centos) it's not cause by Nginx or something because I've tested it using my development mode and it is working normally on Windows machine.
Here is the console log output
As you can see the url is become like https://%22https/ws/?EIO=4&transport=polling&t=O5iOwlU
and the correct url must be like https://example.com/ws/?EIO=4&transport=polling&t=O5iOwlU
It never happened before, it just happened today. and this is my snippets of my code:
const socketOptions = {
reconnection: true,
rejectUnauthorized: false,
path: '/ws',
}
if (process.env.VUE_APP_STATUS === 'development') {
socketBase = `${process.env.VUE_APP_SOCKET}`
} else {
socketBase = `${process.env.VUE_APP_SOCKET_PRODUCTION}`
}
// Vue.use(VueSocketIo, Socket)
Vue.use(
new VueSocketIo({
debug: true,
connection: socketBase,
vuex: {
store,
actionPrefix: 'SOCKET_',
},
options: socketOptions
}),
)
I've tried everything but it still doesn't work. I'm using this lib for my socket io client Vue-Socket.io

prevent ffmpeg from opening console window

I have a node/express server which is used to give streams from IP camera to a website. Everything is working well. I run that webserver with PM2 on a windows server.
The problem : for each stream I have a windows console opening with just nothing logged in. The console reopen when I try to close it.
Is there a way to prevent those console to open ?
Here is the related node.js code :
const { NodeMediaServer } = require('node-media-server');
private _initiate_streams(): void{
DatabaseProvider.instance.camerasDao.getCamerasList().pipe(
take(1)
).subscribe(
(databaseReadOperationResult: DatabaseReadOperationResult<ICamera[]>) => {
if (databaseReadOperationResult.successful === true){
const cameras = databaseReadOperationResult.result;
const tasks = [];
cameras.forEach( camera => {
tasks.push(
{
app : config.get('media_server.app_name'),
mode: 'static',
edge: camera.rtsp_url,
name: camera.stream_name,
rtsp_transport: 'tcp'
}
)
});
const configMediaServer = {
logType: 3, // 3 - Log everything (debug)
rtmp: {
port: 1935,
chunk_size: 60000,
gop_cache: true,
ping: 60,
ping_timeout: 30
},
http: {
port: config.get('media_server.port'),
allow_origin: '*'
},
auth: {
play: true,
api: true,
publish: true,
secret: config.get('salt'),
api_user: 'user',
api_pass: 'password',
},
relay: {
ffmpeg: 'C:\\FFmpeg\\bin\\ffmpeg.exe',
tasks: tasks
}
};
var nms = new NodeMediaServer(configMediaServer)
nms.run();
} else {
// catch exception
}
}
);
}

How to do automation testing of your website on firefox ? (webdriverio)

I am new to automation testing. I followed the steps given on "http://webdriver.io/guide.html" everything went great .
I installed
node.js
selenium-server-standalone-3.5.3
geckodriver
chromeriver
My script goes like this:
var webdriverio = require(.\\webdriverio');
var options = {
desiredCapabilities: {
browserName: 'C:\Program Files\Mozilla Firefox\firefox'
}
};
webdriverio
.remote(options)
.init()
.url('http://www.google.com')
.getTitle().then(function(title) {
console.log('Title was: ' + title);
})
.end()
.catch(function(err) {
console.log(err);
});
This works well but it opens chrome browser where as I want to open firefox.
Switch browserName: 'C:\Program Files\Mozilla Firefox\firefox'
to just browserName: 'firefox'

res.render doesn't render correctly after 1023 characters

I have a parent Express app, and a Ghost app as a child app, using Ghost as an npm module here.
I routed Ghost to be rendered at http://localhost:9000/blog. All the configuration works fine (Ghost will throw an error if the basic configuration isn't being provided correctly).
Here is my Ghost startup code
ghost({
config: path.join(__dirname, '/config/ghost.config.js')
}).then(function (ghostServer) {
app.use(ghostServer.config.paths.subdir, ghostServer.rootApp);
ghostServer.start(app);
});
here is my Ghost config
// # Ghost Configuration
// Setup your Ghost install for various [environments](http://support.ghost.org/config/#about-environments).
// Ghost runs in `development` mode by default. Full documentation can be found at http://support.ghost.org/config/
var path = require('path'),
config;
config = {
// ### Production
// When running Ghost in the wild, use the production environment.
// Configure your URL and mail settings here
production: {
url: 'http://my-ghost-blog.com',
mail: {},
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost.db')
},
debug: false
},
server: {
host: '127.0.0.1',
port: '2368'
}
},
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. in RSS and email.
// Change this to your Ghost blog's published URL.
url: 'http://localhost:9000/blog/',
// Example mail config
// Visit http://support.ghost.org/mail for instructions
// ```
// mail: {
// transport: 'SMTP',
// options: {
// service: 'Mailgun',
// auth: {
// user: '', // mailgun username
// pass: '' // mailgun password
// }
// }
// },
// ```
// #### Database
// Ghost supports sqlite3 (default), MySQL & PostgreSQL
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '../blog/data/ghost-dev.db')
},
debug: false
},
// #### Server
// Can be host & port (default), or socket
server: {
// Host to be passed to node's `net.Server#listen()`
host: '127.0.0.1',
// Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT`
port: '9000'
},
// #### Paths
// Specify where your content directory lives
paths: {
contentPath: path.join(__dirname, '../blog/')
}
},
// **Developers only need to edit below here**
// ### Testing
// Used when developing Ghost to run tests and check the health of Ghost
// Uses a different port number
testing: {
url: 'http://127.0.0.1:2369',
database: {
client: 'sqlite3',
connection: {
filename: path.join(__dirname, '/content/data/ghost-test.db')
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing MySQL
// Used by Travis - Automated testing run through GitHub
'testing-mysql': {
url: 'http://127.0.0.1:2369',
database: {
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'root',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
},
// ### Testing pg
// Used by Travis - Automated testing run through GitHub
'testing-pg': {
url: 'http://127.0.0.1:2369',
database: {
client: 'pg',
connection: {
host : '127.0.0.1',
user : 'postgres',
password : '',
database : 'ghost_testing',
charset : 'utf8'
}
},
server: {
host: '127.0.0.1',
port: '2369'
},
logging: false
}
};
module.exports = config;
So basically, when I go to http://localhost:9000/blog, it isn't being rendered at all. Nothing. I was using Chrome and also testing it using Safari. Also tested those two without JavaScript turned on.
And then I try to do curl http://localhost:9000/blog, and try using a requester app (like Postman) and they returned the correct html string. I also tried to do a curl using the user agent as Chrome and as Safari, it also returns the correct html.
I traced down to ghost node_modules, and the renderer is in ghost > core > server > controllers > frontend > index.js in this line res.render(view, result)
I changed the res.render to be like this
res.render(view, result, function(err, string) {
console.log("ERR", err);
console.log("String", string);
res.send(string);
})
and there is no error, it logs the current string, but it doesn't render anything on the browser.
I tried curl, postman, works, but browser doesn't work.
then I tried to send a hello world string, it works, the browser rendered it.
Then I add the string length one by one, and it turns out, any str.length < 1023 will be able to be rendered by the browser, but once it get past that, it doesn't.
And I tried in my parent Express app, it is able to send string which length is more than 1023, and if I use the ghost module as a standalone, it also able to send string more than 1023.
So something must have happened between those two, but I don't know how to debug this.
Please help

intern.js and Browserstack

Intern.js is a great testrunner but it only appears to work with SauceLabs. My company already uses BrowserStack and are very happy with it. I was wondering if anyone has been able to integrate Intern.js with BrowserStack and if so how?
You should be able to use BrowserStack with the following Intern configuration for Intern 1:
define({
capabilities: {
'browserstack.user': 'your-username',
'browserstack.key': 'your-access-key'
},
webdriver: {
host: 'hub.browserstack.com'
},
useSauceConnect: false
});
or this configuration for Intern 2:
define({
tunnel: 'BrowserStackTunnel',
tunnelOptions: {
username: 'your-username', // or use env var BROWSERSTACK_USERNAME
accessKey: 'your-access-key' // or use env var BROWSERSTACK_ACCESS_KEY
}
});
These settings work for me:
tunnel: 'BrowserStackTunnel',
webdriver: {
username: 'your-useranme',
accessKey: 'your-access-key',
},

Resources