Related
Am running the Selenium webdriver(Maven Project) Scripts through Jenkins by calling pom.xml file. I have set below mentioned browser resolution
driver.manage().window().maximize();
Dimension defaultSize = new Dimension(2560,1440);
driver.manage().window().setSize(defaultSize);
However, while running the scripts through Jenkins, Chrome browser window is not set to the new dimension.
Note : In Local machine it's working fine..
Copied from my question - GOCD pipeline, Selenium ChromeDriver window size is not set
his issue looks to have been caused by two issues,
1- When mvn clean test is run from the IDE this process runs under your current user. However, when run by the Continuous Integration environment, the process is owned by the System process. so does not have the same access to resources.
2 When run from the IDE, chrome will pop up. When run from the CI environment I assumed that it defaulted chrome to run in headless mode. It does not, you have to set the --headless argument so my configuration that now works is as follows
public class GoogleChrome extends Base {
private static final Logger logger = LogManager.getLogger(GoogleChrome.class);
private String rootPath = System.getProperty("user.dir").replace("\\","/");
#Autowired
protected WebDriver driver;
public WebDriver startChromeDriver() {
logger.info("Chrome driver path : " + rootPath + "/../Tools/Drivers/chromedriver.exe");
System.setProperty("webdriver.chrome.driver", rootPath + "/../Tools/Drivers/chromedriver.exe");
Map<String, Object> prefs = new HashMap<String, Object>();
logger.info("Disabling Chrome's credentials service");
prefs.put("credentials_enable_service", false);
logger.info("Disabling Chrome's password manager");
prefs.put("password_manager_enabled", false);
final String regex = "^\\D*$";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(System.getProperty("user.name"));
boolean isHuman = matcher.matches();
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
logger.info("Disabling Chrome's info bars");
options.addArguments("disable-infobars");
options.addArguments("--incognito");
options.addArguments("--disable-gpu");
options.addArguments("--no-sandbox");
options.addArguments("--allow-insecure-localhost");
if (isHuman){
logger.info("Chrome starting maximized - isHuman: " +isHuman + " process run by " +System.getProperty("user.name"));
options.addArguments("--start-maximized");
} else {
logger.info("Chrome starting headless - isHuman: " +isHuman + " process run by " +System.getProperty("user.name")) ;
options.addArguments("--headless");
options.addArguments("--window-size=1980,1080");
}
options.setAcceptInsecureCerts(true);
try {
logger.info("Killing Chrome browser");
Runtime.getRuntime().exec("taskkill /F /IM chrome.exe");
} catch (IOException e) {
logger.error("Task Kill IOException : " + e.getMessage());
}
logger.info("Starting Chrome browser...");
sleep(2);
driver = new ChromeDriver(options);
logger.info("Window size: "+ driver.manage().window().getSize());
driver.manage().timeouts().implicitlyWait(1, TimeUnit.SECONDS);
return driver;
}
}
Chrome disallows setting the size larger than the system's screen resolution width, the problem may be this in your case. Some workaround could be to maximize the window to at least have the largest window available on that system.
While sometimes old chromedriver also cause the issue
If still problem exist then you can change the resolution by chrome option as :
chromeOptions.addArguments("window-size=1936,1056");
Full code will be like :-
System.setProperty("webdriver.chrome.driver","D:\\Workspace\\JmeterWebdriverProject\\src\\lib\\chromedriver.exe");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("window-size=1936,1056");
WebDriver driver = new ChromeDriver(chromeOptions);
driver.get("https://www.google.co.in/");
Hope it will help you :)
I am using selenium web driver and downloading .pdf files from internet using firefox, but i could not able to save these files on local machine using relative path ( i am using windows 7 32 bit machine ). It is working fine if i am using absolute path. But i only want to use relative path as i also need to run it on server later.
My Code:
public static void main(String args[]) throws ClassNotFoundException, IOException{
FirefoxProfile fprofile = new FirefoxProfile();
fprofile.setPreference("browser.download.useDownloadDir", true);
fprofile.setPreference("browser.download.dir", "./Folder");
fprofile.setPreference("browser.download.folderList", 2);
fprofile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf;");
fprofile.setPreference( "browser.download.manager.showWhenStarting", false );
fprofile.setPreference( "pdfjs.disabled", true );
fprofile.setPreference("plugin.scan.plid.all", false);
fprofile.setPreference("plugin.scan.Acrobat", "99.0");
WebDriver driver = new FirefoxDriver(fprofile);
I did something like this in my ruby code
download_directory = File.join(File.absolute_path('../..', File.dirname(__FILE__)),"downloads")
I believe that it will be similiar in java - get absolute path from relative path
Path path = FileSystems.getDefault().getPath("./Folder");
String absolutePath = path.toAbsolutePath().toString();
http://www.javacodex.com/Files/Converting-A-Relative-Path-Into-An-Absolute-Path
are there any ways to set firefox's proxy settings? I found here information about FoxyProxy but when Selenium works, plugins are unactivated in window.
Value for network.proxy.http_port should be integer (no quotes should be used) and network.proxy.type should be set as 1 (ProxyType.MANUAL, Manual proxy settings)
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", 3128);
WebDriver driver = new FirefoxDriver(profile);
I just had fun with this issue for a couple of days and it was hard for me to find an answer for HTTPS, so here's my take, for Java:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "proxy.domain.example.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.domain.example.com");
profile.setPreference("network.proxy.ssl_port", 8080);
driver = new FirefoxDriver(profile);
Gotchas here: enter just the domain and not http://proxy.domain.example.com, the property name is .ssl and not .https
I'm now having even more fun trying to get it to accept my self signed certificates...
Look at the documentation page.
Tweaking an existing Firefox profile
You need to change "network.proxy.http" & "network.proxy.http_port" profile settings.
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", "localhost");
profile.addAdditionalPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
Just to add to the above given solutions.,
Adding the list of possibilities (integer values) for the "network.proxy.type".
0 - Direct connection (or) no proxy.
1 - Manual proxy configuration
2 - Proxy auto-configuration (PAC).
4 - Auto-detect proxy settings.
5 - Use system proxy settings.
So, Based on our requirement, the "network.proxy.type" value should be set as mentioned below.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
WebDriver driver = new FirefoxDriver(profile);
The WebDriver API has been changed. The current snippet for setting the proxy is
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
In case if you have an autoconfig URL -
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("network.proxy.type", 2);
firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://www.etc.com/wpad.dat");
firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost");
WebDriver driver = new FirefoxDriver(firefoxProfile);
Here's a java example using DesiredCapabilities. I used it for pumping selenium tests into jmeter. (was only interested in HTTP requests)
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
String myProxy = "localhost:7777"; //example: proxy host=localhost port=7777
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY,
new Proxy().setHttpProxy(myProxy));
WebDriver webDriver = new FirefoxDriver(capabilities);
For PAC based urls
Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.PAC);
proxy.setProxyAutoconfigUrl("http://some-server/staging.pac");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, proxy);
return new FirefoxDriver(capabilities);
I hope this could help.
According to the latest documentation
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",
}
with webdriver.Firefox() as driver:
# Open URL
driver.get("https://selenium.dev")
Firefox Proxy: JAVA
String PROXY = "localhost:8080";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)setFtpProxy(PROXY).setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
There is another solution, i looked for because a had problems with code like this (it s set the system proxy in firefox):
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "8080");
driver = new FirefoxDriver(profile);
I prefer this solution, it force the proxy manual setting in firefox.
To do that, use the org.openqa.selenium.Proxy object to setup Firefox :
FirefoxProfile profile = new FirefoxProfile();
localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
localhostProxy.setHttpProxy("localhost:8080");
profile.setProxyPreferences(localhostProxy);
driver = new FirefoxDriver(profile);
if it could help...
FirefoxProfile profile = new FirefoxProfile();
String PROXY = "xx.xx.xx.xx:xx";
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy=PROXY;
proxy.FtpProxy=PROXY;
proxy.SslProxy=PROXY;
profile.SetProxyPreferences(proxy);
FirefoxDriver driver = new FirefoxDriver(profile);
It is for C#
Preferences -> Advanced -> Network -> Connection (Configure how Firefox connects to the Internet)
Trying to find a way to disable Firefox from raising a warning every time a connection uses an "untrusted" certificate, with Selenium. I believe that the kind of solution that would work the best would be to set one of the browser preferences.
Just found this from the Mozilla Foundation bug link and it worked for me.
caps.setCapability("acceptInsecureCerts",true)
I found this comment on enabling this functionality in Selenium for Java. There is also this StackOverflow question about the same issue, also for Java For Python, which was my desired target language, I came up with this, through browsing the FirefoxProfile code:
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
Which, as far as I have tested, has produced the expected behavior.
Hope this helps somebody!
No need of custom profiles to deal with "Untrusted connection" on WebDriver
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new FirefoxDriver(capabilities);
None of the above answers worked for me. I'm using:
https://github.com/mozilla/geckodriver/releases/download/v0.12.0/geckodriver-v0.12.0-win64.zip
Firefox 50.1.0
Python 3.5.2
Selenium 3.0.2
Windows 10
I resolved it just by using a custom FF profile which was easier to do than I expected. Using this info https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles#w_starting-the-profile-manager on how to make a custom profile, I did the following:
1) Made a new profile
2) Manually went to the site in FF to raise the untrusted certificate error
3) Add a site exception (when the error is raised click advanced and then add exception)
4) confirm the exception works by reloading the site (you should no longer get the error
5) Copy the newly create profile into your project (for me it's a selenium testing project)
6) Reference the new profile path in your code
I didn't find any of the following lines resolved the issue for me:
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['handleAlerts'] = True
firefox_capabilities['acceptSslCerts'] = True
firefox_capabilities['acceptInsecureCerts'] = True
profile = webdriver.FirefoxProfile()
profile.set_preference('network.http.use-cache', False)
profile.accept_untrusted_certs = True
But using a custom profile as mentioned above did.
Here is my code:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
firefox_capabilities = DesiredCapabilities.FIREFOX
firefox_capabilities['marionette'] = True
#In the next line I'm using a specific FireFox profile because
# I wanted to get around the sec_error_unknown_issuer problems with the new Firefox and Marionette driver
# I create a FireFox profile where I had already made an exception for the site I'm testing
# see https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles#w_starting-the-profile-manager
ffProfilePath = 'D:\Work\PyTestFramework\FirefoxSeleniumProfile'
profile = webdriver.FirefoxProfile(profile_directory=ffProfilePath)
geckoPath = 'D:\Work\PyTestFramework\geckodriver.exe'
browser = webdriver.Firefox(firefox_profile=profile, capabilities=firefox_capabilities, executable_path=geckoPath)
browser.get('http://stackoverflow.com')
From start to finish with all the trimmings, in C#. Note that I had installed FFv48 to a custom directory because GeckoDriver requires that specific version.
var ffOptions = new FirefoxOptions();
ffOptions.BrowserExecutableLocation = #"C:\Program Files (x86)\Mozilla Firefox48\firefox.exe";
ffOptions.LogLevel = FirefoxDriverLogLevel.Default;
ffOptions.Profile = new FirefoxProfile { AcceptUntrustedCertificates = true };
var service = FirefoxDriverService.CreateDefaultService(ffPath, "geckodriver.exe");
var Browser = new FirefoxDriver(service, ffOptions, TimeSpan.FromSeconds(120));
In my case I was using Marionette driver instead of Firefox driver. There is an acknowledged bug (https://bugzilla.mozilla.org/show_bug.cgi?id=1103196) for it. In the meantime I'm using Firefox driver instead:
DesiredCapabilities dc = DesiredCapabilities.firefox();
dc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
dc.setCapability(FirefoxDriver.PROFILE, profile);
// this is the important line - i.e. don't use Marionette
dc.setCapability(FirefoxDriver.MARIONETTE, false);
Webdriver driver = new FirefoxDriver(dc);
C#: Something have changed as options now has own attribute for this.
var ffOptions = new FirefoxOptions();
ffOptions.AcceptInsecureCertificates = true;
Driver = new FirefoxDriver(ffOptions);
Hope this helps.
I added the below and then it worked for me
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
desiredCapabilities.setAcceptInsecureCerts(true);
WebDriver driver = new FirefoxDriver(desiredCapabilities);
For me, using PHP facebook/webdriver I set create a profile and authorised the certified. The name of profile was selenium.
Next I initialise my selenium 3:
java -jar -Dwebdriver.firefox.profile=selenium selenium-server-standalone-3.0.1.jar
Then in FirefoxDriver.php
I set const PROFILE = 'selenium';
This worked for me.
For Firefox driver and Java add these lines:
WebDriver driver;
ProfilesIni profile = new ProfilesIni();
FirefoxProfile testprofile = profile.getProfile("default");
testprofile.setAcceptUntrustedCertificates(true);
testprofile.setAssumeUntrustedCertificateIssuer(true);
driver = new FirefoxDriver(testprofile);
If you use geckodriver don't forget to add this before profile initialization:
System.setProperty("webdriver.gecko.driver","<PATH_TO_GECKODRIVER>\\geckodriver.exe");
In Java you have to use DesiredCapabilities.setAcceptInsecureCerts(). To get a FirefoxDriver with custom capability and profile do the following:
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setAcceptInsecureCerts(true);
FirefoxProfile profile = new FirefoxProfile();
profile.set*...
FirefoxOptions options = new FirefoxOptions();
options.addCapabilities(capabilities);
options.setProfile(profile);
new FirefoxDriver(options);
In my case this did the trick
FirefoxOptions options = new FirefoxOptions();
options.addCapabilities(new ImmutableCapabilities(ImmutableMap.of(
CapabilityType.ACCEPT_SSL_CERTS, true,
CapabilityType.ACCEPT_INSECURE_CERTS, true)));
WebDriver driver = new FirefoxDriver(options);
Above solution worked for me on Firefox 54.0b9 (64-bit). This is my code.
Create your capabilities
Create FF Profile with your requirements
Add 1. & 2. to Firefox Options and pass it to FirefoxDriver
Like below
capabilities = new DesiredCapabilities().firefox();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
//Accept Untrusted connection and to download files
FirefoxProfile profile = new FirefoxProfile();
profile.setAcceptUntrustedCertificates(true);
profile.setAssumeUntrustedCertificateIssuer(false);
profile.setPreference("dom.file.createInChild", true);
profile.setPreference("browser.download.folderList", 1);
profile.setPreference("browser.helperApps.alwaysAsk.force", false);
profile.setPreference("browser.download.manager.showWhenStarting"
,false);
profile.setPreference("pdfjs.disabled", true );
profile.setPreference("browser.helperApps.neverAsk.saveToDisk"
,"application/pdf;image/jpg;image/jpeg;text/html;text/plain;application/zip;application/download");
System.setProperty("webdriver.gecko.driver", config.getGeckoDriver());
capabilities.setCapability(FirefoxDriver.PROFILE, profile);
FirefoxOptions options = new FirefoxOptions();
options.addCapabilities(capabilities);
options.setProfile(profile);
driver=new FirefoxDriver(options);
This configuration works for me in PHP
public function setUp()
{
$this->setHost('localhost');
$this->setPort(4444);
$this->setBrowserUrl('https://example.loc');
$this->setBrowser('firefox');
$this->setDesiredCapabilities(["acceptInsecureCerts" => true]);
}
For Firefox I run
java -jar selenium-server-standalone-3.8.1.jar -enablePassThrough false
I was having this issue useing Node JS and Selenium. Searched everywhere but could not find anything.
Finally got it. Maybe this will help someone.
var webdriver = require('selenium-webdriver');
driver = new webdriver.Builder()
.withCapabilities({'browserName': 'firefox', acceptSslCerts: true, acceptInsecureCerts: true})
.build()
for PHP please use below code
$serverUrl = 'http://localhost:4444/wd/hub';
$capabilities = new DesiredCapabilities(
[
'browserName' => 'firefox',
'proxy' => [
'proxyType' => 'manual',
'httpProxy' => 'localhost:0000',
'sslProxy' => 'localhost:XXXX',
],
]
);
$capabilities->setCapability('acceptInsecureCerts',True);
$driver = RemoteWebDriver::create($serverUrl, $capabilities,60*1000,60*1000);
are there any ways to set firefox's proxy settings? I found here information about FoxyProxy but when Selenium works, plugins are unactivated in window.
Value for network.proxy.http_port should be integer (no quotes should be used) and network.proxy.type should be set as 1 (ProxyType.MANUAL, Manual proxy settings)
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", 3128);
WebDriver driver = new FirefoxDriver(profile);
I just had fun with this issue for a couple of days and it was hard for me to find an answer for HTTPS, so here's my take, for Java:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", "proxy.domain.example.com");
profile.setPreference("network.proxy.http_port", 8080);
profile.setPreference("network.proxy.ssl", "proxy.domain.example.com");
profile.setPreference("network.proxy.ssl_port", 8080);
driver = new FirefoxDriver(profile);
Gotchas here: enter just the domain and not http://proxy.domain.example.com, the property name is .ssl and not .https
I'm now having even more fun trying to get it to accept my self signed certificates...
Look at the documentation page.
Tweaking an existing Firefox profile
You need to change "network.proxy.http" & "network.proxy.http_port" profile settings.
FirefoxProfile profile = new FirefoxProfile();
profile.addAdditionalPreference("network.proxy.http", "localhost");
profile.addAdditionalPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
Just to add to the above given solutions.,
Adding the list of possibilities (integer values) for the "network.proxy.type".
0 - Direct connection (or) no proxy.
1 - Manual proxy configuration
2 - Proxy auto-configuration (PAC).
4 - Auto-detect proxy settings.
5 - Use system proxy settings.
So, Based on our requirement, the "network.proxy.type" value should be set as mentioned below.
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.type", 1);
WebDriver driver = new FirefoxDriver(profile);
The WebDriver API has been changed. The current snippet for setting the proxy is
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "3128");
WebDriver driver = new FirefoxDriver(profile);
In case if you have an autoconfig URL -
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("network.proxy.type", 2);
firefoxProfile.setPreference("network.proxy.autoconfig_url", "http://www.etc.com/wpad.dat");
firefoxProfile.setPreference("network.proxy.no_proxies_on", "localhost");
WebDriver driver = new FirefoxDriver(firefoxProfile);
Here's a java example using DesiredCapabilities. I used it for pumping selenium tests into jmeter. (was only interested in HTTP requests)
import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
String myProxy = "localhost:7777"; //example: proxy host=localhost port=7777
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY,
new Proxy().setHttpProxy(myProxy));
WebDriver webDriver = new FirefoxDriver(capabilities);
For PAC based urls
Proxy proxy = new Proxy();
proxy.setProxyType(Proxy.ProxyType.PAC);
proxy.setProxyAutoconfigUrl("http://some-server/staging.pac");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.PROXY, proxy);
return new FirefoxDriver(capabilities);
I hope this could help.
According to the latest documentation
from selenium import webdriver
PROXY = "<HOST:PORT>"
webdriver.DesiredCapabilities.FIREFOX['proxy'] = {
"httpProxy": PROXY,
"ftpProxy": PROXY,
"sslProxy": PROXY,
"proxyType": "MANUAL",
}
with webdriver.Firefox() as driver:
# Open URL
driver.get("https://selenium.dev")
Firefox Proxy: JAVA
String PROXY = "localhost:8080";
org.openqa.selenium.Proxy proxy = new org.openqa.selenium.Proxy();
proxy.setHttpProxy(PROXY)setFtpProxy(PROXY).setSslProxy(PROXY);
DesiredCapabilities cap = new DesiredCapabilities();
cap.setCapability(CapabilityType.PROXY, proxy);
WebDriver driver = new FirefoxDriver(cap);
There is another solution, i looked for because a had problems with code like this (it s set the system proxy in firefox):
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("network.proxy.http", "localhost");
profile.setPreference("network.proxy.http_port", "8080");
driver = new FirefoxDriver(profile);
I prefer this solution, it force the proxy manual setting in firefox.
To do that, use the org.openqa.selenium.Proxy object to setup Firefox :
FirefoxProfile profile = new FirefoxProfile();
localhostProxy.setProxyType(Proxy.ProxyType.MANUAL);
localhostProxy.setHttpProxy("localhost:8080");
profile.setProxyPreferences(localhostProxy);
driver = new FirefoxDriver(profile);
if it could help...
FirefoxProfile profile = new FirefoxProfile();
String PROXY = "xx.xx.xx.xx:xx";
OpenQA.Selenium.Proxy proxy = new OpenQA.Selenium.Proxy();
proxy.HttpProxy=PROXY;
proxy.FtpProxy=PROXY;
proxy.SslProxy=PROXY;
profile.SetProxyPreferences(proxy);
FirefoxDriver driver = new FirefoxDriver(profile);
It is for C#
Preferences -> Advanced -> Network -> Connection (Configure how Firefox connects to the Internet)