How to Disable "Chrome --disable-web-security" in Jmeter Webdriver Sampler? - javascript

We are trying to Performance Test one of our web Applications which has Security feature enabled using JMeter and we are unable to pass Chrome --disable-web-security in webdriver Sampler and was wondering do we have any option to pass Chrome --disable-web-security when the webdriver sampler launches the chrome Browser ?
Below is the sample command line which we are using to disable web security manually to test the application.
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --disable-web-security --user-data-dir="chrome"

Unfortunately you cannot, you can ask WebDriver Sampler plugin developers or maintainers to include this option into one of the future releases via JMeter Plugins Support Forum
In the meantime you can switch to JSR223 Sampler and write your Selenium-related code in Groovy language, it will give you full control and flexibility, example code:
System.setProperty('webdriver.chrome.driver', '/path/to/chromedriver')
def options = new org.openqa.selenium.chrome.ChromeOptions()
options.addArguments('--disable-web-security')
def chromedriver = new org.openqa.selenium.chrome.ChromeDriver(options)
chromedriver.get('http://example.com')

Enabling the Chrome Driver Config Option, "Allow Insecure Certs" worked well for my requirement.Could be worth a try.
Chrome Driver Config Screenshot

Related

TypeError: 'NoneType' object is not subscriptable while invoking execute_script() for Chrome Download Manager through Selenium

I have been using this function https://stackoverflow.com/a/48267887/11220889 for waiting for downloads to finish and returning the file path once finished. And it has been working great until now.
The Function
def every_downloads_chrome(driver):
if not driver.current_url.startswith("chrome://downloads"):
driver.get("chrome://downloads/")
return driver.execute_script('''
var items = downloads.Manager.get().items_;
if (items.every(e => e.state === "COMPLETE"))
return items.map(e => e.file_url);
''')
How its called
paths = WebDriverWait(driver, 120, 1).until(every_downloads_chrome)
Error I'm receiving
TypeError: 'NoneType' object is not subscriptable
So from what I can gather something has changed that has started causing the function to not return a path. I believe this is due to a change within chrome or even more specifically the chrome driver. My two reasons for this assumption is:
1) I had this function in another code that my colleague was using and she called me saying it was producing this error yesterday.
2)Neither code has changed so the change must be in chrome
I would like to keep using this script but if not possible have another function that waits for the downloads to finish and returns the paths and ideally does it all through the driver not through file path since multiple users use my codes on multiple machines.
EDIT: Versions-
Name: selenium
Version: 3.141.0
Name: Chrome Browser
Version: 73.0.3683.86
Name: Chrome Driver
Version: 2.43.600210
Name: System
Version: Windows 10 Pro x64
As per the error message:
TypeError: 'NoneType' object is not subscriptable
Your main issue seems to be incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.43
Release Notes of chromedriver=2.43 clearly mentions the following :
Supports Chrome v69-71
You are using chrome=73.0
Release Notes of ChromeDriver v2.46 clearly mentions the following :
Supports Chrome v71-73
So there is a clear mismatch between ChromeDriver v2.43 and the Chrome Browser v73.0
Solution
Upgrade ChromeDriver to current ChromeDriver v2.46 level.
Keep Chrome version at Chrome v73 level. (as per ChromeDriver v2.46 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
Update
Currently GAed Chrome v73 have some issues and you may like to downgrade to Chrome v72. You can find a couple of relevant discussions in:
Getting Timed out receiving message from renderer: 600.000 When we execute selenium scripts using Jenkins windows service mode
Timed out receiving message from renderer: 10.000 while capturing screenshot using chromedriver and chrome through Jenkins on Windows

How to debug Node.js with Firefox?

I'm aware of how to access the Chrome Dev Tools with Google Chrome to debug Node.js applications: just go to about://inspect.
I encountered a line of text on MDN mentioning that Firefox could be used for Node.js applications, but going to about://inspect in Firefox doesn't work. I'd like to know how this would be done in Firefox, if it is indeed possible.
Because Firefox uses a different Javascript engine (Gecko) than Node.js (V8), it's impossible to use the Firefox dev tools to debug Node scripts. As of this post, MDN says as much in their "Remote Debugging" article:
You can connect the developer tools to Gecko-based runtimes...
https://developer.mozilla.org/en-US/docs/Tools/Remote_Debugging
There's a tool called node-firefox that you can use for that, you can download it from:
npm install node-firefox
Here's the source code: https://github.com/mozilla/node-firefox
And a introductory guide: https://hacks.mozilla.org/2015/02/introducing-node-firefox/

ERROR for jp#gc - Firefox Driver Config

Hi All,
When i run the web page using Jmeter webdriver sampler in my device with (Indian server) I can achieve my task successfully without any issues, but when the same .jmx file is run on another device with (US server) it throws an error (I have attached that error as image format). I am sure that there is no issues in scripting and please let me know, what could I do to over come this issue?
Most likely your "US Server" doesn't have WebDriver Set plugin installed. You will need to install WebDriver Set on the "US Server" and restart JMeter there to pick up the new libraries.
The fastest and the easiest way of installing JMeter Plugins and keeping them up to date is using JMeter Plugins Manager, the relevant package is Selenium/WebDriver Support

What is a good headless browser to run with protractor?

New User here.
After hours of building my smoke and regression tests, I found out after reading many cases online that phantomjs is known to be a trouble to run with protractor. Jenkins has been running phantomjs for all the tasks it has been given so far.
They need these tests to run as part of ci which does not have a windowing system installed.
So I would appreciate it if there is a recommendation for completely headless browser or a headless chrome(that would be most beneficial) and a step by step to set it up. I already have a conf.js and a e2e.conf.js file. My code works perfectly fine with chrome.
I am on a iMac and selenium webdriver, I believe.
Edit: Problem = protractor doesn't work with phantomjs.
What I have done = use different web elements and googled if anyone has faced a similar situation. Also googled for headless browsers that worked for protractor, unable to find a suitable solution.
If anyone reached here - the answers are outdated.
Chromium (on next release) now supports headless mode. no need to work hard.
You can read more here:
https://developers.google.com/web/updates/2017/04/headless-chrome
Here is an example from command line
chrome \
--headless \ # Runs Chrome in headless mode.
--disable-gpu \ # Temporarily needed for now.
--remote-debugging-port=9222 \
https://www.chromestatus.com # URL to open. Defaults to about:blank.
And you can simply trigger protractor with capabilities for chrome:
Activating chrome language flags when activating from protractor (selenium)
Here is the configuraiton I am using
capabilities: {
'browserName': browserName,
chromeOptions: {
binary: '/Users/guymograbi/Downloads/chrome-mac/Chromium.app/Contents/MacOS/Chromium',
args: ['--headless','--disable-gpu']
}
},
Update - new versions of chrome doesn't require binary property
In my environments I found I can remove the binary property as new version of chrome is available on stable branches
My protractor configuration is
capabilities: {
'browserName': 'chrome',
chromeOptions: {
args: [ '--headless', '--disable-gpu', '--no-sandbox', '--window-size=1920x1200' ]
},
},
And it works smoothly for weeks now. highly recommended.
Update - how to do this in karma is super easy
Using headless chrome in karma is super easy:
browsers: 'ChromeHeadless'
it should work with the chrome loader and everything. more info
Your best bet is to continue with Chrome. With a bit of work you can get it to work via a CI and in a headless manner - we do this using Jenkins and Docker Ubuntu servers which are headless.
You will need to configure Chrome to run headless using XVFB. You can start off by following the gist here https://gist.github.com/addyosmani/5336747
You state you are on a Mac so you can either run the headless tests via Docker on your machine or you could set up a second config for the CI tests.
Another resource http://tobyho.com/2015/01/09/headless-browser-testing-xvfb/
I would continue testing in normal browsers with a head, but would use a remote selenium server as a service - Sauce Labs or BrowserStack, see:
Integration Testing with Protractor, WebdriverJS and Sauce Labs
Running Protractor tests on Browserstack Automate
automate-node-samples
You could run your Protractor tests against CodeShip or Drone.io, both of which offer Chrome and/or Firefox running headless for free. No really...
If you've got Chrome 59+ installed, start Chrome with the following flag:
--headless
please let me know if you need more help, will write the config for you :) enjoy

How to debug remote v8-based application using Chrome Dev Tools

v8 has its own JSON based remote-debugging protocol and two UI debuggers:console application D8 and a eclipse plugin(hosted at http://code.google.com/p/chromedevtools)
Chrome use WebKit Remote Debugging Protocol including Console, DOM Debugger, ..., Debugger
"WebKit Remote Debugging Protocol" is a Google Chrome/Chromium debug protocol. You will find its description at http://developers.google.com/chrome-developer-tools/docs/remote-debugging
So is it possible to use the Chrome Dev Tools ships with chrome to debug remote v8-based application?
Try Node Webkit Agent for NodeJS version >= 0.6
Node-inspector is for NodeJS version 0.4
The setup need to be set in your node server and access the URL provided by the library base on your node version. You cannot use Developer Tools in Chrome directly.
node-inspector is designed to do exactly what you ask.
It seems that it competes with Node Webkit Agent. I haven't tried webkit agent yet as it seems newer and it failed to install without some meddling. node-inspector worked for me, and fairly well, although there is a bit of latency from running a statement to getting the output marshaled into Chrome's debugger. Overall, it's an extremely useful tool.

Categories