Error 403 Forbidden on Selenium grid due to proxy issue

While I have been conducting website tests using Selenium webdriver on my local machine, I now aim to perform these tasks on a Windows EC2 instance. After researching, I discovered that Selenium Grid2 can be utilized on EC2 servers. However, upon setting up and connecting the nodes to the hub, I encountered errors when running JavaScript in Eclipse.

The commands I used are:

To initialize the hub: java -jar selenium-server-standalone-2.46.0.jar -role hub

To link a node to the hub: java -jar selenium-server-standalone-2.46.0.jar -role webdriver -hub http://:4444/grid/register/ -port 5555

The code snippet is as follows:

package com.example.grid;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class seleniumgridclass {    
    //Remote webdriver instance
    public static RemoteWebDriver driver;
    public static void main(String[] args) throws MalformedURLException {

        DesiredCapabilities cap = new DesiredCapabilities().firefox();
        cap.setPlatform(Platform.VISTA);
        cap.setBrowserName("firefox");      
        driver = new RemoteWebDriver(new URL("http://<ip addr of node>:5555/wb/hub"),cap);      
        driver.navigate().to("http://www.google.com");      
        driver.findElementByName("q").sendKeys("execute automation");       
        driver.findElementByName("btnG").click();       
    }
}

I am encountering the following error:

Exception in thread "main" org.openqa.selenium.UnsupportedCommandException: <html>
<head>
<title>Error 403 Forbidden for Proxy</title>
</head>            
<body>
<h2>HTTP ERROR: 403</h2><pre>Forbidden for Proxy</pre>
<p>RequestURI=/wb/hub/session</p>
<p><i><small><a href="http://jetty.mortbay.org">Powered by Jetty://</a></small></i></p>                                               

</body>
</html>
Command duration or timeout: 218 milliseconds
Build info: version: '2.46.0', revision: '87c69e2', time: '2015-06-04 16:17:10'
System info: host: 'WIN-Y636DAAY2OH', ip: '10.0.1.226', os.name: 'Windows Server 2008', os.arch: 'x86', os.version: '6.0', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    at java.lang.reflect.Constructor.newInstance(Unknown Source)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:204)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:156)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:605)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:242)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:128)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:155)
    at com.example.grid.seleniumgridclass.main(seleniumgridclass.java:26)

Please offer guidance on how to resolve the Proxy Forbidden 403 Error issue.

Answer №1

The problem stems from a typographical error in your code. It is necessary to make the following adjustment:

driver = new RemoteWebDriver(new URL("http://<ip address of node>:5555/wb/hub"),cap);

Change it to:

driver = new RemoteWebDriver(new URL("http://<ip address of node>:5555/wd/hub"),cap);

Please take note of the modification from wb to wd.

Furthermore, it is recommended that you direct your connection towards the Hub rather than the IP address of your node. By doing so, you can fully utilize the capabilities of the Hub and effectively route your tests to specific nodes instead of directly targeting a single node.

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

Using MongoDB to group by the difference in dates and retrieve the hour value

Currently, I am working on an application and I require some information from my database: I have a model called "traitement" which includes a user, The "traitement" model has a start date and an end date, both in Date format, allowing MongoDB to use ISO ...

Generating a unique image switch with disabled hover functions

My latest project involves coding a block that displays an image on an HTML page, with a new image appearing each time the user hovers over it. However, there's a glitch in my code that causes the images to flicker erratically if the mouse is moved ev ...

A guide on verifying discrepancies between selected record data in two tables

How can I validate if the data of selected records is mismatching in two tables? I need to select a few records in each table. Upon clicking the Match button, if the currencies are not the same, we need to display an alert saying "Data mismatched". I have ...

Modify the class of a div element depending on the value of a data attribute

I am faced with a situation where I have an iframe and two different sets of CSS codes - one for landscape orientation and one for portrait orientation. However, these are not specifically for the device's orientation but rather for the content loaded ...

Leveraging ng-class for designing a favorite symbol

How can I implement ng-class to toggle an icon when it is clicked, taking into account whether it is stored in local storage? For example, changing the favorite icon from outline to solid upon user click. Below is my current implementation using ng-class ...

Collect all the attribute values of the checkboxes that have been checked and convert them

Is there a way to retrieve the attribute values of all checked checkboxes as an XML string? <input type="checkbox" id="chkDocId1" myattribute="myval1"/> <input type="checkbox" id="chkDocId2" myattribute="myval43"/> <input type="checkbox ...

Hiding elements in HTML with React when data is null

Is there a way to hide elements using classes like "d-none" when the data is null in React? <span className="product__tag">{prod.tag1}</span> <span className="product__tag">{prod.tag2}</span> <span classN ...

Mapping an HTTP object to a model

Currently facing an issue with mapping an http object to a specific model of mine, here is the scenario I am dealing with: MyObjController.ts class MyObjController { constructor ( private myObj:myObjService, private $sco ...

What is the process for advancing to the next or previous step using Angular.js?

I am currently utilizing ui-route for routing purposes, specifically for navigating through a series of sequential forms. After submitting one form, I would like to automatically move on to the next step without hard coding the step name in the $state.go( ...

Is there a way to prevent the onClick event from executing for a particular element in React?

Currently working with Material UI, I have a TableRow element with an onClick event. However, I now need to incorporate a checkbox within the table. The checkbox is enclosed in a TableCell element, which is nested within the TableRow. The issue arises wh ...

Incorporating a variety of functions into an external javascript file

I am currently working on enhancing the functionality of a basic HTML page by incorporating JavaScript with multiple buttons. The problem arises when I attempt to introduce another function in my external JS file, as it causes the existing code to stop wor ...

What is the best way to swap out the if else statement with a Ternary operator within a JavaScript function?

Is there a way to replace the if else statement in the function using a Ternary operator in JavaScript? private getProductName(productType: string): string { let productName = 'Product not found'; this.deal.packages.find(p => p.isSele ...

The 'name' property of Axios and Vuex is not defined and cannot be read

When making a call to axios in my mounted function to retrieve profile data, I send the payload to the 'set_account' Vuex store upon success. To access this data, I utilize MapGetters (currentAccount) in computed properties. However, when tryin ...

Can you explain the functionality of driver.navigate().to() in Selenium? Specifically, I am curious about the purpose and usage of navigate() and

I'm feeling a bit confused right now. Whenever we create an object of a class, we are able to access its properties and methods. That part I understand. However, when we create an object of the WebDriver class in Selenium and set a URL using driver.na ...

Storing information from a table into LocalStorage

$('.new_customer').click(function () { var table = $("table"); var number = table.find('tr').length; table.append('<tr id="' + number + '"><td><input type="button" class="btn btn-success btn-xs" ...

Tips for retrieving a variable from an XML file with saxonjs and nodejs

I came across an xml file with the following structure: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE agent SYSTEM "http://www.someUrl.com"> <myData> <service> <description>Description</description> < ...

What is the best way to transfer variables from an ng-template defined in the parent component to a child component or directive?

Is there a way to pass an ng-template and generate all its content to include variables used in interpolation? As I am still new to Angular, besides removing the HTML element, do I need to worry about removing anything else? At the end of this ...

Automated testing on a website devoid of any elements or Xpath expressions

Do you know of a test automation tool that can manage a website without any elements, xpaths, or IDs (essentially without a DOM)? When I examine the DOM Explorer in the IE browser, I only see 'script' paths. The developers informed me that these ...

The redirection to the HTML page happens too soon, causing the ASYNC functions to fail in saving the user's image and data to the server

Hey everyone! I'm facing an issue with async/await functions. Here's the code snippet from my backend where I'm trying to save details of a newly registered user. I'm puzzled as to why the Redirect() function is executing before the f ...

Tips for choosing the default tab on Bootstrap

I have a question about an issue I am facing with my Angular Bootstrap UI implementation. Here is the code snippet: <div class="container" ng-controller='sCtrl'> <tabset id='tabs'> <tab heading="Title1"> ...