Having difficulty configuring Firefox profile, proxy settings, and authentication using Java

Hello Selenium Webdriver Experts,

I've made adjustments to my Firefox profile setup in hopes of integrating FireBug when launching Firefox through Selenium Webdriver 2:

public static void main(String[] args) 
{
    File fireBugFile = new File("C:/selenium-ide-1.9.0.xpi");
    FirefoxProfile firefoxProfile = new FirefoxProfile();
    firefoxProfile.addExtension(fireBugFile);
    firefoxProfile.setPreference("network.proxy.type", 1);
    firefoxProfile.setPreference("network.proxy.http", "proxyserver");
    firefoxProfile.setPreference("network.proxy.http_port", "80");
    firefoxProfile.setPreference("extensions.firebug.currentVersion", "1.9.0");

    String urlStrProxy = "http://www.example.com/",
    proxy = "proxyserver",
    port = "80",
    username = "jack",
    password = "XXXXXXX";

    Authenticator.setDefault(new SimpleAuthenticator(username,password));
    Properties systemProperties = System.getProperties();
    systemProperties.setProperty("http.proxyHost",proxy);
    systemProperties.setProperty("http.proxyPort","80");

    WebDriver driverMainPage = new FirefoxDriver(firefoxProfile);
}

public class SimpleAuthenticator extends Authenticator
{
   private String username, password;

   public SimpleAuthenticator(String username,String password)
   {
       this.username = username;
       this.password = password;
   }

   protected PasswordAuthentication getPasswordAuthentication()
   {
       return new PasswordAuthentication(username,password.toCharArray());
   }
}

I have also tried additional statements to include proxy settings and authentication details to bypass the proxy server pop-up issue while accessing www.abc.com without success:

In addition, I added "-Dhttp.proxyHost=proxyserver -Dhttp.proxyPort=80 -Dhttp.proxyUser=jack -Dhttp.proxyPassword=XXXXXXX" as a JVM option.

My environment includes Java 7, Selenium 2.25.0, Netbeans 7.2 on Windows XP and 7.

I have not found a direct answer to this question in my searches.

Your help would be greatly appreciated.

Thank you, Jack

Answer №1

It seems that the port number must be specified as an integer within the code snippet:

firefoxProfile.setPreference("network.proxy.http_port", 80);

To deal with the login prompt requesting username and password, you can utilize autoit.

Answer №2

According to the code provided, Selenium IDE is being used instead of Firebug. Take a look:

  File fireBugFile = new File("C:/selenium-ide-1.9.0.xpi");
FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.addExtension(fireBugFile);

This could be the reason why Firebug is not working. Make sure to provide the correct location and version of Firebug compatible with your Firefox.

In the past, I have used the following method for authentication without considering Firefox profiles:

driver.get("http://UserName:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1343726060647c617753566b727e637f763d707c">[email protected]</a>");

I have also manually created a Firefox profile for authentication purposes, which worked well when called in the execution process.

Thank you.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps for uploading a file with WebdriverIO

Currently, I am in the process of converting this Ruby code using the selenium-webdriver gem into Node.js with WebdriverIO: @webdriver.navigate.to "https://imgur.com/upload" element = @webdriver.find_element(:id, 'global-files-button') element.s ...

Ubuntu compatibility with chrome-driver 83

Currently using Ubuntu 18.04.1 LTS with Google Chrome version 83 and corresponding chrome-driver version 83 successfully for a while, I recently encountered an issue after updating to the latest stable versions: google-chrome-stable v83.0.4103.61 and chrom ...

The issue with Protractor's sendkeys function is that it requires an X display for converting keycodes

I've encountered an issue while attempting to execute Protractor e2e tests in a Vagrant VM using headless Chrome. Despite successfully configuring Xvfb, I face an error when trying to fill out a form: unknown error: an X display is required for keycod ...

The setTimeout functionality is executing faster than expected

In my selenium test, I've noticed that the setTimeout function consistently finishes about 25% faster than it should. For example, when waiting for 20 seconds, the function completes after only 15 seconds. test.describe('basic login test',f ...

Executing Nightwatch.js Upload Command

Looking to develop a nightwatch action that involves uploading files to a specific upload form. Can an action like this be created within the nightwatch framework? Nightwatch is linked to a nodejs app and operates through a selenium webdriver. ...

Issue with installing chromedriver and selenium-driver on Windows 7 using NPM arise

I have a relatively basic package.json file with some development dependencies included. Here is what it looks like: "devDependencies": { "cssnano": "3.3.2", "cucumber": "0.9.2", "diff": "2.2.0", "grunt": "0.4.5", "jit-grunt": "0.9.1", " ...

Converting hexadecimal string to a double value in Java

Currently, I am working on decoding the value of the "Well-known Binary" format using Java. The Node script below accomplishes this task: Buffer.from('A4C0A7DEBFC657C0', 'hex').readDoubleLE() // returns -95.1054608 I am struggling to f ...

Single Linked List - retrieve and insert functions

Today I'm tackling the challenge of implementing an SLList class by completing operations such as: get(i), set(i, x), add(i, x), and remove(i), all designed to run in O(1 + i) time. The areas where I'm encountering issues in my program are part ...

Connecting to WS Protocol in Android devicesorHow to

After developing a Node.js server for my client that utilizes WebSocket technology, I successfully tested it using JavaScript. Now, my goal is to integrate this connection into my application. The server communicates through the WS protocol (ws://) and sen ...

Why am I getting the error "Chai assert.isBoolean is not defined as a function"?

Snippet of code: driver.wait(function(){ return driver.isElementPresent(webdriver.By.className(errElement)); }, 3000, 'Element' + errElement + ' is not found').then(function(binaryVariable){ assert.isTrue(binaryVariable, &apos ...

Having difficulty incorporating custom JavaScript files into a testing framework

I am facing a unique challenge while integrating the Page Object design pattern into my test suite using selenium-webdriver and node.js. The first page object, pageObject/admin/login/index.js, works seamlessly. It contains selectors and methods to fill ou ...

Creating a node server that will intercept all requests from an Angular frontend (using http) and route them to a

Currently, I am utilizing express on node for routing and incorporating Angular as the front-end framework. Additionally, Redis is being used for session management. My objective is to ensure that whenever an HTTP request is made from Angular, it first goe ...

The DevToolsActivePort file for Selenium on Heroku cannot be found

I'm currently in the process of deploying a node and selenium application to Heroku. Here is a snippet of my code: let options = new Options(); options.setChromeBinaryPath(process.env.GOOGLE_CHROME_BIN); options.addArguments("headless"); options.addAr ...

Error Alert: Fatal issue encountered while utilizing a Java npm package

Currently in my Meteor application, I am utilizing the 'node-excel-api' npm package which has a dependency on the 'java' npm package. Upon starting up the Meteor server, I encountered the following error message: A critical error has b ...

The functionality of Webdriver.waitUntil is not meeting the expected outcomes

I'm currently utilizing webdriverio version 4.5: ./node_modules/.bin/wdio -v v4.5.2 In my scenario, I am in need of waiting for the existence of a specific element and handling the situation if it doesn't exist. Here is an example code snippet ...

The error message "NoSuchSessionError: invalid session id" pops up in Selenium, despite the fact that the application is running smoothly

Scenario and Background: I have recently developed a script to access an external website and extract specific data. The script's purpose is to retrieve grades of students and convert them into usable data for plotting. In order to streamline the dat ...

Utilizing the same WebDriverJS instance repeatedly

As a beginner in Selenium, I successfully launched a website using the following Node.js code snippet: var webdriver = require('selenium-webdriver'); var driver = new webdriver.Builder() .forBrowser('chrome') .build(); console ...

Steps to effortlessly retrieve a CSV file using Selenium without dealing with the bothersome file dialog

I've been attempting to access a URL with a CSV file for download in a specific directory by using the Selenium Webdriver for Firefox (geckodriver) in a NodeJS environment on Linux-Mint. Here's the code I'm working with: const {Builder} = r ...

"Exploring the dynamic capabilities of Node.JS and Java Publisher/Subscriber

I am working on developing an application where communication will be facilitated through a node.js server. This node server is responsible for receiving messages from other peers. Here is the code snippet for my node.js: var zmq = require('zmq&apos ...

Tips for interacting with a custom web component using Selenium WebDriver

As a newcomer to writing selenium tests, I am attempting to create an automated test for a carousel feature on our homepage. The objective is to click on one of the carousel navigation buttons and then confirm that a specific inline style has been applied ...