Guidelines for implementing socks authentication in webdriverio

I'm facing an issue with enabling SOCKSv5 authentication in my webdriverio application. Unfortunately, the current configurations don't seem to be working.

Here are the configurations I've tried so far:

  1. Setting manually using firefox-profile:
fp.setProxy({ 
    proxyType: 'manual', 
    socksProxy: `127.0.0.1:1080`,
    socksUsername: 'myuser',
    socksPassword: 'mypass'
});

This method didn't work as expected, as the pages aren't loading.

  1. Using FoxyProxy

Attempting to set the URL using its API:

proxy:host=${proxy}&port=1080&isSocks=true&enabled=true&username=myuser&password=mypass

This resulted in a warning indicating that something is accessing its configuration and declining the request.

Creating a custom Firefox profile and then loading it doesn't work either since I need to edit proxies during the runtime of the application.

  1. Updating selenium (3.3) and geckodriver (1.15) with the following configurations:
requiredCapabilities: {
    proxy:{
        proxyType: 'manual',
        socksProxy: '127.0.0.1',
        socksProxyPort: 1080,
        socksVersion: 5,
        socksUsername: "mine",
        socksPassword: "mine"
    }
}

or

desiredCapabilities: {
    proxy:{
        proxyType: 'manual',
        socksProxy: '127.0.0.1',
        socksProxyPort: 1080,
        socksVersion: 5,
        socksUsername: "mine",
        socksPassword: "mine"
    }
}

Unfortunately, neither of these methods worked. I also tried passing the proxy as a JSON.stringify(proxyObj) instead of the direct object.

Here's how I run the entire stack:

var options = { 
    desiredCapabilities: {
        browserName: 'firefox',
        proxy:{
            proxyType: 'manual',
            socksProxy: '127.0.0.1',
            socksProxyPort: 1080,
            socksVersion: 5,
            socksUsername: "mine",
            socksPassword: "mine"
        }
    }
};

var client = webdriverio.remote(options);
client
    .init()   
    .url('http://whatsmyip.org/')
    .end();

Has anyone found a solution for this issue?

log

D:\Users\Maxim\Desktop\test>java -jar -Dwebdriver.geckodriver.driver="D:\Users\Maxim\Desktop\test\geckodriver.exe --log debug" selenium-server-standalone-3.3.0.jar
...(Truncated for brevity)

Answer №1

It has come to my attention that the mozilla team has recently introduced their own browser automation tool named marionette. Along with this, they have created a proxy called geckodriver to act as an intermediary between a webdriver-compatible client and marionette. These tools are currently in active development, so certain aspects may not function as expected. I recommend reviewing this bug report for guidance on setting up a proxy using the necessary capabilities option.

I personally encountered a similar issue in the past and had to make modifications to geckodriver myself. While there have been improvements since then, I am uncertain about the changes made and how to integrate required capabilities with webdriverio and nodejs, especially when using python and its bindings.

Could you experiment with the following configuration:

var options = {
    desiredCapabilities: {
        requiredCapabilities: {
        proxy:{
            proxyType: 'manual',
            socksProxy: '127.0.0.1',
            socksProxyPort: 1080,
            socksVersion: 5,
            socksUsername: "mine",
            socksPassword: "mine"
        }
    }
}

If my understanding is correct, geckodriver looks for requiredCapabilities within capabilities. This aligns with the w3c specification of the webdriver protocol.

Based on your responses, it appears that the issue lies in authenticating at the proxy level. Upon inspecting marionette's source code, I noticed that while there are unit tests for testing socks proxies, these tests do not verify if the username/password are configured properly. This leaves uncertainty regarding its functionality.

I suggest exploring the possibility of managing authentication on the proxy end. For instance, if the proxy supports IP-based authentication, consider setting that up to restrict traffic to your IP address only.

If needed, you can explore using alternative browsers instead of relying solely on firefox.

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

Click the JavaScript button to activate the delete function

Imagine an interactive HTML table where a user can easily delete rows by either selecting a row and pressing the delete key on their keyboard or by clicking a designated delete button. This functionality ensures a smooth and intuitive user experience. Se ...

A guide on extracting split values and assigning them to individual variables

Currently, I'm working on a project utilizing node.js, express, mongo, and socket.io. After successfully retrieving geolocation coordinates and storing them in a hidden input field, I encountered an issue when attempting to save the data into the data ...

Issue detected with Bundler: Configuration object is not valid. The initialization of Webpack used a configuration object that does not align with the API schema

I am currently struggling to make my bundler compile properly. When trying to get it working, I encountered this error message in my terminal along with my webpack.config.js file. Here is the issue reported by the terminal: Invalid configuration object. ...

Updating AngularJS scope does not occur when a value is selected using jQuery

When writing a test using cucumber and selenium, I encountered an issue with a dropdown selection. After selecting a value using jQuery, pressing next resulted in an error. The problem seems to be that Angular has not updated its scope properly. <sele ...

Adjusting the focus of an element with jQuery based on coordinates and offset values

jQuery.fn.getCoord = function(){ var elem = $(this); var x = elem.offset().left; var y = elem.offset().top; console.log('x: ' + x + ' y: ' + y); ); return { x, y }; }; This custom jQuery funct ...

Selenium testing - Immediate disappearance of OK/Cancel popup

Something strange is happening here. When I manually test this, I click the delete button, wait for the popup to appear https://i.sstatic.net/6PMS4.png and then click OK to remove the record successfully. However, when I attempt the same process in Java/Se ...

The order of execution in AngularJS: Understanding the flow

I have taken over the responsibility of managing someone else's website, and while going through the codebase, I came across a snippet that looks like the one below (with some code omitted for simplicity): var Application = (function ($, global) ...

Exploring a JavaScript file with the power of JavaScript and HTML

I have a .js file that contains the following data (excerpt for brevity) var albums= "tracks":[ {"title":"Dunnock","mp3":"Birdsong-Dunnock.mp3", "lyrics":"The Dunnock or hedge sparrow has a fast warbling song often delivered from t ...

bootstrap modal dialog displayed on the edge of the webpage

I am facing an issue with a modal dialog that pops up when clicking on a thumbnail. The JavaScript code I used, which was sourced online, integrates a basic Bootstrap grid layout. The problem arises when half of the popup extends beyond the edge of the pa ...

Is there a way to retrieve metadata from a web URL, like how Facebook automatically displays information when we share a URL in a status update?

Is there a way to fetch metadata such as title, logo, and description from a website URL using AngularJS or JavaScript? I am looking for a solution similar to Facebook's status update feature that automatically loads metadata when you paste a website ...

Modifying the color of specific sections of SVG elements

Interested in utilizing the d3.js timeknots component, a svg visualization that includes line and circle elements. My goal is to implement a stopwatch animation that dynamically changes the color of the svg visualization over time. I am contemplating crea ...

Developing custom node modules for efficient exporting and importing using the Babel transpiler

In a separate project, my goal is to replicate the following structure: import { FuncA, FuncB, FuncC } from @myorg/hellow For an internal project, I am creating my own node module with the folder organization of hellow as outlined below: ...

Clearing browsing data with Robot Class

I'm currently utilizing Selenium to run A/B tests on my webpage, but I'm encountering an issue where I'm not seeing the expected different experiences. I attempted to resolve this by deleting the cookies using: driver.manage().deleteAllCooki ...

AngularJS Service Implementing the Pub/Sub Design Pattern

I've been browsing for solutions to a problem and stumbled upon an answer provided by Mark Rajcok angular JS - communicate between non-dependend services However, I am struggling to fully grasp his explanation, particularly this part: angular.forEa ...

Ways to transmit information from a modal to a function

Trying to figure out how to update data in an ng-grid after submitting a modal form with multiple text input controls. Should the ajax create function be called within the $scope.open controller section or resolve? $scope.open = function (size) { var mo ...

How does the functionality of $.ajax differ from that of $.get?

Similar Inquiry: Understanding the Variations of $.ajax(), $.get(), and $.load() I'm curious about the disparities between $.get() and $.ajax The given code showcases calls like this: $.get(href) .success(function (content) { $(&apos ...

Is there a way in Python to modify a character within an element that has been located by xpath using Selenium?

When using Selenium in Python, I am trying to retrieve the text of an element from a specific xpath. Once I have retrieved the text, I want to check if it contains a special character "-", and replace it with "0". However, every time I attempt this, I enco ...

Is it possible to precisely position multiple children in a relative manner?

I am currently developing a custom dropdown menu where I want the parent element to be relatively positioned within the page. The goal is for all the child elements of the dropdown menu (the list items) to appear as if they are part of a select element and ...

Scroll effortlessly to the middle, bottom, and top of the page in vue.js using arrow keys for a seamless

I'm interested in implementing a feature that allows users to scroll smoothly up and down the page using the arrow keys. When the first down key is pressed, I'd like to smoothly scroll to the middle (50%) of the page, and when the second down ...

Sharing objects among multiple classes in TestNG and Selenium

When it comes to running my test cases with Selenium + TestNG, I encounter an issue due to the spread of my test cases across multiple classes. Ideally, I would like to utilize the same instance of webDriver in each class without having to log in repeate ...