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.