Relaxing Microsoft Edge CSP while running tests (webdriver) (Content-Security-policy) - selenium

I'm trying to relax Microsoft Edge CSP while running a test using proctractor (webdriver, chromedriver).
So the solution can be either
flag like "--disable-csp" which dose not exist according to my search results.
setting for webdriver/protractor to do so.
load an extension that dose that ( Like in chrome
Relaxing Chrome's CSP while running tests (webdriver) (Content-Security-policy))
I could not find any solution but to setup a proxy that filters the header.
any ideas?

I figured the best approach would be to use the solution from the same question for Chrome and just to convert the Chrome extension to a Microsoft-Edge one.
Follow the linked question to the point you got.
Convert the Chrome extension to an Edge extension using this tool
Use the extensionPath option to load the extension the.

Related

running selenium tests via jmeter on blazemeter remotely

We have a jmeter test that launches selenium scripts using the chrome driver config plugin which runs with the Web Driver Sampler, with which we are uploading our own chrome driver. The driver wont be allowed to work though, we keep getting
java.lang.IllegalStateException: The driver is not executable: /tmp/artifacts/chromedriver
we need a way to chmod +x the driver or something similar. is there a way to do this?
Blazemeter support said
JMeter's Webdriver plugin has been deprecated and is not supported on BlazeMeter
but I don't see anything deprecating the webdriver plugin from jmeter The repo and main website seem updated and active.
https://github.com/undera/jmeter-plugins-webdriver
https://jmeter-plugins.org/wiki/WebDriverSampler/?utm_source=jmeter&utm_medium=helplink&utm_campaign=WebDriverSampler
TL/DR: Can we run a selenium test from within a jmeter test using a <com.googlecode.jmeter.plugins.webdriver.sampler.WebDriverSampler on blazemeter? what are the steps to do so?
I hit this exact issue, this is probably too late for you but I thought it would be useful to answer for someone else in the future.
According to this Blazemeter Post titled:
"Using Selenium with JMeter's WebDriver Sampler"
"To launch the WebDriver test in the cloud with more concurrent users on BlazeMeter, use Firefox, which is the only currently supported browser for use with WebDriver. Create a new test and upload your JMX file to run it."
So in summary, only firefox is supported, not chrome within Blazemeter.
I work on a lot of BlazeMeter's documentation and can verify the previous answer -- the Webdriver plugin for JMeter is no longer supported on BlazeMeter.
That's not to say you can't get it to work -- you might -- but it's not supported (i.e. the support team can't assist with any problems that arise with it).
Some added context: We know folks in the plugin development community, which is how we learned the plugin is "deprecated" in the sense that there's not much in the way of future development for it going forward. You're right though - it's not documented anywhere, unfortunately. I can't speak to why that is on the plugin side, but that's why it is no longer supported on the BlazeMeter side.
The other reason it's no longer supported is that we recently introduced a new feature to replace it, our "GUI Functional Test" feature in BlazeMeter, which lets you run Selenium tests either through our BlazeMeter UI or from your own IDE, then watch a recording of what happened in the browser afterward. We have a set of guides covering the topic, starting here:
https://guide.blazemeter.com/hc/en-us/articles/360000700158
We also introduced a means to run a Selenium test alongside a JMeter test, via what we call our End User Experience Monitoring feature, detailed here:
https://guide.blazemeter.com/hc/en-us/articles/360000262118
(That blog post referenced above is a very old one that unfortunately no longer applies today. I regrettably don't work on the blog side of the house, so I don't have the authority to update that one myself.)
Lastly, please let me know if there's any pain points in our docs that we can fix. I've been putting a lot of work into improving and expanding our existing documentation, so feedback is always welcome.

How to run TestCafe tests with throttling connection?

I need to check functionality if a file is uploading longer then 1 minute.
To check it with manual testing I use Chrome Dev Tools to set Throttling "Slow 3G".
But I can't figure out how to do it with TestCafe.
TestCafe does not have an API to set the throttling. However, TestCafe uses Chrome DevTools Protocol internally so you can get access to internal CDP methods.
Please refer to the following links to get started:
Chrome DevTools Protocol
chrome-remote-interface package
chrome-remote-interface repo
Please also take a look at the following example which shows how to enable file downloading in chrome headless.
I think you need to combine this example with the CDP Network.emulateNetworkConditions method.
Please refer to this article https://chromedevtools.github.io/devtools-protocol/tot/Network#method-emulateNetworkConditions

Working with multiple APIs for Multi-platform apps

I currently have a Chrome extension that uses Chrome's APIs and plan on making a Microsoft Edge version once it opens up as well. My question is how do you work with the multiple API's?
For example, I use the following to check if the extension has just been installed or not:
chrome.runtime.onInstalled
I'm assuming for Edge it would be something like:
edge.runtime.onInstalled
What's the best way to work with both of these? Do I just duplicate the code within the file where there is a copy of the code for one and the other and presumably the browser will ignore the other browser's code? (doesn't sound like the good option)
Or is there some cross-browser framework that I should use instead?
Or is there some other solution?
And please forgive me, this is my first entry into building extensions/apps, I'm generally just a Web Designer.
Thank you!
All browsers support or
chrome.runtime.onInstalled
or
browser.runtime.onInstalled
So, the right way is to start scripts in your extension with this code:
var browser = browser || chrome
And then use browser, for example:
browser.runtime.onInstalled
(I'm sorry about my english)
Edit:
Chrome and Opera support chrome and not browser.
Firefox support chrome and browser.
Edge support browser and I don't know if it support chrome.
Anyway, my solution work in all browsers.
Update (5.8.16):
Edge support browser and not chrome.

Selenium - Chrome Web Driver - Html Only, No Images

I am doing a lot of testing with the Chrome Web Driver within Selenium. The problem is that every time I run it, it has to re-download all the site images which takes time. It does not keep these images cached.
So I would like to set which files to render and which not too. Obviously I want Javascript and CSS files to still download. But I particularily want to turn off images.
Is this possible? If not, is there a way to enable caching? So the next time I run the progran it can get the images from the local cache.
The solution is to load the same chrome profile again, it should (may not) ensure that images & other similar things are cached.
Here is how to load a particular profile :
https://code.google.com/p/selenium/wiki/ChromeDriver
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("chrome.switches", Arrays.asList("--user-data-dir=/path/to/profile/directory"));
WebDriver driver = new ChromeDriver(capabilities);
A similar search on SO, gave this result - Load Chrome Profile using Selenium WebDriver using java you might bother to take a look.
Caching from one session to another is not possible as far as I know.
However, it is possible to remove rendering the page if you run it headless. This will load the page, but not render it (make it visible, load images).
You can use HTMLUnitDriver, which is the standard, but somewhat outdated, or you can use PhantomDriver, which has a more modern version of Javascript.
"You can use HTMLUnitDriver" >>> careful with this!
Please note that since HTMLUnitDriver is not the same implementation as the real browser, you may or may not get the same results in both.
So if you start hitting weird issues, like running the test with Chrome passes but running the test with HTMLUnitDriver does not, consider just running your tests with the browser driver. I've heard of looong troubleshooting stories from colleagues and they had to give up on running their suites in headless mode (ie, using HTMLUnitDriver).
NOTE: since I cannot leave a comment on the selected answer, I am "forced" to leave it as an answer. If somebody can help me convert it in a comment, I will appreciate! thanks
For caching images you would need something like squid or haproxy, and then proxy your selenium browser through it.

rspec/capybara/selenium testing - downloading/visit external urls and checking for content type

I understand that in order for capybara to visit external urls, the driver has to be one that supports that (such as selenium). But when selenium is used, I can no longer check for the content type via page.response_headers since that is not supported by the selenium driver. Is there any alternative to response_headers, or am I simply looking at the wrong set of tools?
I use the capybara-webkit driver and I can confirm that page.response_headers works for external sites.