Ho to set acceptInsecureCerts for Firefox in Chimp.js framework? - firefox

I'm automating a website and sometimes it uses an ip address as url, that ip address generates a connection is not secure message in Firefox. Researching online I found out that for Firefox, the default in chimp is acceptInsecureCerts = False. That doesn't happen to Chrome as the default is acceptInsecureCerts = True.
How can I change that in Chimp to make it also work in Firefox? Do I need to create a profile? If so, how can I do that? Thanks!

This is more of a WebdriverIO config than Chimp. See here how you can set acceptInsecureCerts using the desiredCapabilities section of the config like this:
module.exports {
webdriverio: {
desiredCapabilities: {
browserName": "firefox",
acceptInsecureCerts": true
}
}
}
The config above goes in the Chimp config file. See here for details
See the full Chimp config here
See the Webdriver.io config here
See the desiredCapbilities support for webdriver here
Note that browsers have their own extra desiredCapabilities, like Chrome for example.

Related

navigator.share is set on desktop Firefox but doesn't do anything

I have some code like this:
if (navigator.share) {
navigator.share({
title: 'example',
url: 'http://example.com',
});
}
According to this documentation for navigator.share on MDN, desktop browsers do not support the Web Share API, and navigator.share is undefined in those browsers.
However, when I run this code in desktop Firefox, navigator.share is defined and set to a function that doesn't seem to do anything when called.
It probably is a browser extension that is setting navigator.share. Try disabling all your extensions.
In my case, it turned out to be this extension: Plasma Integration by KDE.

Set firefox profile with protractor

I want to run tests with Firefox/protractor with the cache feature disabled.
(Actually, I'm trying to prevent 304 HTTP responses).
There are multiple ways to do this:
Disable the cache from the backend-side by droping Etag headers -> I can't modify the backend
Drop the Etag header from the frontend-side -> I tried, it did not work
Disable the cache from firefox: I just have to set the flag network.http.use-cache to false
Manually it works. I receive only 200 responses and it's great.
I want to be able to set this flag through protractor configuration. After some search I found out that I had to create a custom profile and set it in protractor this way (https://code.google.com/p/selenium/wiki/DesiredCapabilities):
capabilities: {
browserName: 'firefox',
firefox_profile: 'support/firefox_profile'
}
The problem is that the firefox profile is not considered. Is it the right option?
Do you have a better idea?
Thanks for your help.
EDIT:
As someone (suggested
capabilities: {
prefs: {
'config.http.use-cache': false
}
}
It did not work - I checked in about:config, the flag was still enabled.
How do you know what options you can pass in the capabilities?
Here's an example of how to integrate firefox-profile with protractor: https://github.com/juliemr/protractor-demo/tree/master/howtos/setFirefoxProfile
EDIT: For those upgrading to protractor >=1.6, the old way of doing this was broken because 'browser' can no longer return a promise. The demo has been updated.

Dynamically changing proxy in Firefox with Selenium webdriver

Is there any way to dynamically change the proxy being used by Firefox when using selenium webdriver?
Currently I have proxy support using a proxy profile but is there a way to change the proxy when the browser is alive and running?
My current code:
proxy = Proxy({
'proxyType': 'MANUAL',
'httpProxy': proxy_ip,
'ftpProxy': proxy_ip,
'sslProxy': proxy_ip,
'noProxy': '' # set this value as desired
})
browser = webdriver.Firefox(proxy=proxy)
Thanks in advance.
This is a slightly old question.
But it is actually possible to change the proxies dynamically thru a "hacky way"
I am going to use Selenium JS with Firefox but you can follow thru in the language you want.
Step 1: Visiting "about:config"
driver.get("about:config");
Step 2 : Run script that changes proxy
var setupScript=`var prefs = Components.classes["#mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefs.setIntPref("network.proxy.type", 1);
prefs.setCharPref("network.proxy.http", "${proxyUsed.host}");
prefs.setIntPref("network.proxy.http_port", "${proxyUsed.port}");
prefs.setCharPref("network.proxy.ssl", "${proxyUsed.host}");
prefs.setIntPref("network.proxy.ssl_port", "${proxyUsed.port}");
prefs.setCharPref("network.proxy.ftp", "${proxyUsed.host}");
prefs.setIntPref("network.proxy.ftp_port", "${proxyUsed.port}");
`;
//running script below
driver.executeScript(setupScript);
//sleep for 1 sec
driver.sleep(1000);
Where use ${abcd} is where you put your variables, in the above example I am using ES6 which handles concatenation as shown, you can use other concatenation methods of your choice , depending on your language.
Step 3: : Visit your site
driver.get("http://whatismyip.com");
Explanation:the above code takes advantage of Firefox's API to change the preferences using JavaScript code.
As far as I know there are only two ways to change the proxy setting, one via a profile (which you are using) and the other using the capabilities of a driver when you instantiate it as per here. Sadly neither of these methods do what you want as they both happen before as you create your driver.
I have to ask, why is it you want to change your proxy settings? The only solution I can easily think of is to point firefox to a proxy that you can change at runtime. I am not sure but that might be possible with browsermob-proxy.
One possible solution is to close the webdriver instance and create it again after each operation by passing a new configuration in the browser profile
Have a try selenium-wire, It can even override header field
from seleniumwire import webdriver
options = {
'proxy': {
"http": "http://" + IP_PORT,
"https": "http://" + IP_PORT,
'custom_authorization':AUTH
},
'connection_keep_alive': True,
'connection_timeout': 30,
'verify_ssl': False
}
# Create a new instance of the Firefox driver
driver = webdriver.Firefox(seleniumwire_options=options)
driver.header_overrides = {
'Proxy-Authorization': AUTH
}
# Go to the Google home page
driver.get("http://whatismyip.com")
driver.close()

selenium rc turn off proxy firefox

My issue is caused by incorrect 'proxy' settings in Firefox so I want to disable the proxy in the profile that Selenium uses for my tests.
Currently my profile looks for the local proxy settings file by default:
file:///C:/Users/%username%/AppData/Local/Temp/customProfileDir536e1d9817834e4e838cad55697fc909/proxy.pac
That file contains these 3 lines:
function FindProxyForURL(url, host) {
return 'PROXY localhost:4444; DIRECT';
}
If during the tests I open the settings and set 'no proxy', the app starts working fine. How can I make the tests always launch with the 'no proxy' setting?
I tried to use the -avoidProxy flag when running the Selenium server but that hasn't helped. I also tried using a separate profile for tests but Selenium overrides its settings as well.
Create a new firefox browser profile & set the preferences in it as per your requirement.
Start selenium server with this profile using the switch -firefoxProfileTemplate <path_to_firefox>

How to enable/disable forefox addon using javascript

I want to enable the addon which is disabled manually after firefox restart .I can listen the events for enable/disable firefox addon with the methods "onDisabling: function(addon, needsRestart)" .Can I enable the extension using javascript.any ideas would be appreciated?
You can use Add-on Manager API for this. Something along these lines:
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("someextension#example.com", function(addon)
{
if (addon.userDisabled)
addon.userDisabled = false;
});
Here someextension#example.com stands for the ID of the add-on you want to enable of course.

Resources