Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to selenium 3.14.0. #420

Open
wants to merge 4 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions SeleniumGridExtras/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
</repositories>

<properties>
<version.selenium>3.8.1</version.selenium>
<version.selenium>3.14.0</version.selenium>
</properties>

<dependencies>
Expand Down Expand Up @@ -74,7 +74,7 @@
<dependency> <!-- Selenium 3.7.1 comes with gson 2.8.2 -->
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.2</version>
<version>2.8.4</version>
</dependency>
<dependency>
<groupId>net.coobird</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void initialize() {
getConfigMap().put(NODE_ADDITIONAL_CLASSPATH, new ArrayList<String>());
getConfigMap().put(GRID_JVM_OPTIONS, new HashMap<String, Object>());
getConfigMap().put(GRID_EXTRAS_JVM_OPTIONS, new HashMap<String, Object>());
getConfigMap().put(GRID_EXTRAS_PORT, 3000);
getConfigMap().put(GRID_EXTRAS_PORT, "3000");

getConfigMap().put(AUTO_UPDATE_DRIVERS, "");
getConfigMap().put(AUTO_UPDATE_BROWSER_VERSIONS, "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,36 @@ public class GridNode {
// Selenium 3 has values at top level, not in "configuration"
private String proxy;
private ArrayList<String> servlets = new ArrayList<String>();
private Integer maxSession;
private Integer port;
private String maxSession;
private String port;
private Boolean register;
private Integer unregisterIfStillDownAfter;
private Integer hubPort;
private String unregisterIfStillDownAfter;
private String hubPort;
private String hubHost;
private String host;
private String url;
private Integer registerCycle;
private Integer nodeStatusCheckTimeout;
private String registerCycle;
private String nodeStatusCheckTimeout;
private String appiumStartCommand;
private Map<String, Object> custom = new HashMap();

private String browserTimeout;
private String timeout;

public void setBrowserTimeout(Integer browserTimeout) {
if (browserTimeout != null)
this.browserTimeout = String.valueOf(browserTimeout);
}

public void setTimeout(Integer timeout) {
if (timeout != null)
this.timeout = String.valueOf(timeout);
}

private Map<String, Object> custom = new HashMap();

//Only test the node status 1 time, since the limit checker is
//Since DefaultRemoteProxy.java does this check failedPollingTries >= downPollingLimit
private Integer downPollingLimit;
private String downPollingLimit;

private static Logger logger = Logger.getLogger(GridNode.class);

Expand All @@ -59,14 +73,14 @@ public GridNode(boolean isSelenium3) {
configuration = new GridNodeConfiguration();
} else {
proxy = "com.groupon.seleniumgridextras.grid.proxies.SetupTeardownProxy";
maxSession = 3;
maxSession = "3";
register = true;
unregisterIfStillDownAfter = 10000;
registerCycle = 5000;
nodeStatusCheckTimeout = 10000;
downPollingLimit = 0;
unregisterIfStillDownAfter = "10000";
registerCycle = "5000";
nodeStatusCheckTimeout = "10000";
downPollingLimit = "0";
// Init custom with grid_extras_port value from node
custom.put(Config.GRID_EXTRAS_PORT, RuntimeConfig.getGridExtrasPort());
custom.put(Config.GRID_EXTRAS_PORT, String.valueOf(RuntimeConfig.getGridExtrasPort()));
}
}

Expand Down Expand Up @@ -108,25 +122,36 @@ public static GridNode loadFromFile(String filename, boolean isSelenium3) {
int nodePort = 0;
if(isSelenium3) { // This won't work for beta1, beta2, or beta3.
try {
hubPort = Integer.parseInt(topLevelJson.get("hubPort").toString());
hubPort = Integer.parseInt(topLevelJson.get("hubPort").getAsString());
hubHost = topLevelJson.get("hubHost").getAsString();
nodePort = Integer.parseInt(topLevelJson.get("port").toString());
nodePort = Integer.parseInt(topLevelJson.get("port").getAsString());
GridNode node = new GridNode(filteredCapabilities, null, hubPort, hubHost, nodePort);
node.setMaxSession(Integer.parseInt(topLevelJson.get("maxSession").toString()));
node.setMaxSession(Integer.parseInt(topLevelJson.get("maxSession").getAsString()));
node.setProxy(topLevelJson.get("proxy").getAsString());
node.setRegister(topLevelJson.get("register").getAsBoolean());
node.setRegisterCycle(topLevelJson.get("registerCycle") != null
? Integer.parseInt(topLevelJson.get("registerCycle").toString()) : null);
? Integer.parseInt(topLevelJson.get("registerCycle").getAsString()) : null);
node.setUnregisterIfStillDownAfter(topLevelJson.get("unregisterIfStillDownAfter") != null
? Integer.parseInt(topLevelJson.get("unregisterIfStillDownAfter").toString()) : null);
? Integer.parseInt(topLevelJson.get("unregisterIfStillDownAfter").getAsString()) : null);
node.setNodeStatusCheckTimeout(topLevelJson.get("nodeStatusCheckTimeout") != null
? Integer.parseInt(topLevelJson.get("nodeStatusCheckTimeout").toString()) : null);
? Integer.parseInt(topLevelJson.get("nodeStatusCheckTimeout").getAsString()) : null);
node.setDownPollingLimit(topLevelJson.get("downPollingLimit") != null
? Integer.parseInt(topLevelJson.get("downPollingLimit").toString()) : null);
node.setHost(topLevelJson.get("host") != null ? topLevelJson.get("host").getAsString() : null);
node.setUrl(topLevelJson.get("url") != null ? topLevelJson.get("url").getAsString() : null);
node.setAppiumStartCommand(topLevelJson.get("appiumStartCommand") != null
? Integer.parseInt(topLevelJson.get("downPollingLimit").getAsString()) : null);
node.setHost(
topLevelJson.get("host") != null && !topLevelJson.get("host").isJsonNull()
? topLevelJson.get("host").getAsString() : null);
node.setUrl(
topLevelJson.get("url") != null && !topLevelJson.get("url").isJsonNull()
? topLevelJson.get("url").getAsString() : null);
node.setAppiumStartCommand(
topLevelJson.get("appiumStartCommand") != null && !topLevelJson.get("appiumStartCommand").isJsonNull()
? topLevelJson.get("appiumStartCommand").getAsString() : null);
node.setBrowserTimeout(
topLevelJson.get("browserTimeout") != null && !topLevelJson.get("browserTimeout").isJsonNull()
? Integer.parseInt(topLevelJson.get("browserTimeout").getAsString()) : null);
node.setTimeout(
topLevelJson.get("timeout") != null && !topLevelJson.get("timeout").isJsonNull()
? Integer.parseInt(topLevelJson.get("timeout").getAsString()) : null);

// Adding custom-config see Issue #342
Type type = new TypeToken<Map<String, Object>>(){}.getType();
Expand All @@ -136,7 +161,9 @@ public static GridNode loadFromFile(String filename, boolean isSelenium3) {
// Init custom with grid_extras_port value from node if it doesn't exist
if (!customMap.containsKey(Config.GRID_EXTRAS_PORT))
{
customMap.put(Config.GRID_EXTRAS_PORT, RuntimeConfig.getGridExtrasPort());
customMap.put(Config.GRID_EXTRAS_PORT, String.valueOf(RuntimeConfig.getGridExtrasPort()));
} else {
customMap.put(Config.GRID_EXTRAS_PORT, String.valueOf(customMap.get(Config.GRID_EXTRAS_PORT)));
}
node.setCustom(customMap);
}
Expand Down Expand Up @@ -251,19 +278,21 @@ public void setLoadedFromFile(String file) {

// Selenium 3 requires these at the root
public int getPort() {
return port;
return Integer.parseInt(port);
}

public void setPort(Integer port) {
this.port = port;
if (port != null)
this.port = String.valueOf(port);
}

public int getHubPort() {
return hubPort;
return Integer.parseInt(hubPort);
}

public void setHubPort(Integer hubPort) {
this.hubPort = hubPort;
if (hubPort != null)
this.hubPort = String.valueOf(hubPort);
}

public String getHubHost() {
Expand Down Expand Up @@ -291,11 +320,12 @@ public void setUrl(String url) {
}

public int getMaxSession() {
return this.maxSession;
return Integer.parseInt(this.maxSession);
}

public void setMaxSession(Integer maxSession) {
this.maxSession = maxSession;
if (maxSession != null)
this.maxSession = String.valueOf(maxSession);
}

public boolean getRegister() {
Expand All @@ -307,11 +337,12 @@ public void setRegister(Boolean register) {
}

public int getRegisterCycle() {
return registerCycle;
return Integer.parseInt(registerCycle);
}

public void setRegisterCycle(Integer registerCycle) {
this.registerCycle = registerCycle;
if (registerCycle != null)
this.registerCycle = String.valueOf(registerCycle);
}

public String getProxy() {
Expand All @@ -331,23 +362,25 @@ public ArrayList<String> getServlets() {
}

public int getNodeStatusCheckTimeout() {
return nodeStatusCheckTimeout;
return Integer.parseInt(nodeStatusCheckTimeout);
}

public void setNodeStatusCheckTimeout(Integer nodeStatusCheckTimeout) {
this.nodeStatusCheckTimeout = nodeStatusCheckTimeout;
if (nodeStatusCheckTimeout != null)
this.nodeStatusCheckTimeout = String.valueOf(nodeStatusCheckTimeout);
}

public int getUnregisterIfStillDownAfter() {
return unregisterIfStillDownAfter;
return Integer.parseInt(unregisterIfStillDownAfter);
}

public void setUnregisterIfStillDownAfter(Integer unregisterIfStillDownAfter) {
this.unregisterIfStillDownAfter = unregisterIfStillDownAfter;
if (unregisterIfStillDownAfter != null)
this.unregisterIfStillDownAfter = String.valueOf(unregisterIfStillDownAfter);
}

public void setDownPollingLimit(Integer downPollingLimit) {
this.downPollingLimit = downPollingLimit;
this.downPollingLimit = String.valueOf(downPollingLimit);
}

public String getAppiumStartCommand() {
Expand Down Expand Up @@ -484,6 +517,9 @@ public class GridNodeConfiguration {
private int nodeStatusCheckTimeout = 10000;
private String appiumStartCommand;

private String browserTimeout;
private String timeout;

//Only test the node status 1 time, since the limit checker is
//Since DefaultRemoteProxy.java does this check failedPollingTries >= downPollingLimit
private int downPollingLimit = 0;
Expand Down Expand Up @@ -603,6 +639,22 @@ public String getAppiumStartCommand() {
public void setAppiumStartCommand(String appiumStartCommand) {
this.appiumStartCommand = appiumStartCommand;
}

public String getBrowserTimeout() {
return browserTimeout;
}

public void setBrowserTimeout(String browserTimeout) {
this.browserTimeout = browserTimeout;
}

public String getTimeout() {
return timeout;
}

public void setTimeout(String timeout) {
this.timeout = timeout;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
import org.openqa.grid.internal.TestSlot;
import org.openqa.grid.internal.utils.HtmlRenderer;
import org.openqa.grid.selenium.proxy.DefaultRemoteProxy;
import org.openqa.grid.web.utils.BrowserNameUtils;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

import java.util.Map;

Expand Down Expand Up @@ -73,7 +71,6 @@ public String renderSummary() {
}

private String getIcon(Map<String, Object> capabilities) {
return BrowserNameUtils.getConsoleIconPath(new DesiredCapabilities(capabilities),
proxy.getRegistry());
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might not be right. Depending on the browser it should return icon for the browser.

	  public static String getConsoleIconPath(DesiredCapabilities cap, GridRegistry registry) {
	    String name = consoleIconName(cap, registry);
	    String path = "org/openqa/grid/images/";
	    InputStream in =
	        Thread.currentThread().getContextClassLoader()
	            .getResourceAsStream(path + name + ".png");
	    if (in == null) {
	      return null;
	    }
	    return "/grid/resources/" + path + name + ".png";
	  }

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe you are right. But this is just how we run, not sure where this is used ... It was the quickest way to get rid of BrowserNameUtils.
I can update the code if you want.
In my changes, there was some dead code that I removed, rather than updating it, like a servlet in this PR.

Copy link
Contributor

@shankarkc shankarkc Aug 16, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its used in grid console page...I am not sure though. I looked at old code and copy pasting it here so that it helps you to fix it quickly

 private static String consoleIconName(DesiredCapabilities cap, GridRegistry registry) {
	    String browserString = cap.getBrowserName();
	    if (browserString == null || "".equals(browserString)) {
	      return "missingBrowserName";
	    }

	    String ret = browserString;

	    // Map browser environments to icon names.
	    if (browserString.contains("iexplore") || browserString.startsWith("*iehta")) {
	      ret = BrowserType.IE;
	    } else if (browserString.contains("firefox") || browserString.startsWith("*chrome")) {
	      if (cap.getVersion() != null && cap.getVersion().toLowerCase().equals("beta") ||
	          cap.getBrowserName().toLowerCase().contains("beta")) {
	        ret = "firefoxbeta";
	      } else if (cap.getVersion() != null && cap.getVersion().toLowerCase().equals("aurora") ||
	          cap.getBrowserName().toLowerCase().contains("aurora")) {
	        ret = "aurora";
	      } else if (cap.getVersion() != null && cap.getVersion().toLowerCase().equals("nightly") ||
	          cap.getBrowserName().toLowerCase().contains("nightly")) {
	        ret = "nightly";
	      } else {
	        ret = BrowserType.FIREFOX;
	      }

	    } else if (browserString.startsWith("*safari")) {
	      ret = BrowserType.SAFARI;
	    } else if (browserString.startsWith("*googlechrome")) {
	      ret = BrowserType.CHROME;
	    } else if (browserString.toLowerCase().contains("edge")) {
	      ret = BrowserType.EDGE;
	    }

	    return ret.replace(" ", "_");
	  }


	  /**
	   * get the icon representing the browser for the grid. If the icon cannot be located, returns
	   * null.
	   *
	   * @param cap - Capability
	   * @param registry - Registry
	   * @return String with path to icon image file.  Can be null if no icon
	   *         file if available.
	   */
	  public static String getConsoleIconPath(DesiredCapabilities cap, GridRegistry registry) {
	    String name = consoleIconName(cap, registry);
	    String path = "org/openqa/grid/images/";
	    InputStream in =
	        Thread.currentThread().getContextClassLoader()
	            .getResourceAsStream(path + name + ".png");
	    if (in == null) {
	      return null;
	    }
	    return "/grid/resources/" + path + name + ".png";
	  }

}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void testCustomConfigurationFromFile() throws Exception {
" \"customString\": \"custom\",\n" +
" \"customInt\": 1,\n" +
" \"customBoolean\": false,\n" +
" \"grid_extras_port\": 3000\n" +
" \"grid_extras_port\": \"3000\"\n" +
" }"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GridExtrasDownloaderTest {
public static final String EXPECTED_VERSION = "1.10.1";
public static final String EXPECTED_1101_DOWNLOAD_URL = "https://github.com/groupon/Selenium-Grid-Extras/releases/download/1.10.1/SeleniumGridExtras-1.10.1-SNAPSHOT-jar-with-dependencies.jar";
public static final String GRID_EXTRAS_RELEASE_API_URL = "https://api.github.com/repos/groupon/Selenium-Grid-Extras/releases";
public static final String EXPECTED_171_URL = "https://github.com/groupon/Selenium-Grid-Extras/releases/download/v1.7.1/SeleniumGridExtras-1.7.1-SNAPSHOT-jar-with-dependencies.jar";
public static final String EXPECTED_201_URL = "https://github.com/groupon/Selenium-Grid-Extras/releases/download/v2.0.1/SeleniumGridExtras-2.0.1-SNAPSHOT-jar-with-dependencies.jar";
public static final String EXPECTED_JAR_NAME = "SeleniumGridExtras-1.10.1-SNAPSHOT-jar-with-dependencies.jar";
public static final int GRID_EXTRAS_AUTO_UPDATE_CHECK_INTERVAL = 2000;
private GridExtrasDownloader downloader;
Expand Down Expand Up @@ -123,8 +123,8 @@ public void testGetDownloadJarUrl() throws Exception {

GridExtrasDownloader downloader2 = new GridExtrasDownloader();

downloader2.setVersion("1.7.1");
assertEquals(EXPECTED_171_URL, downloader2.getJarUrl());
downloader2.setVersion("2.0.1");
assertEquals(EXPECTED_201_URL, downloader2.getJarUrl());
}

@Test
Expand Down