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

Unrecognized platform: mac-unknown-64bit #4781

Closed
RajAsapu opened this issue Sep 28, 2017 · 20 comments
Closed

Unrecognized platform: mac-unknown-64bit #4781

RajAsapu opened this issue Sep 28, 2017 · 20 comments
Labels

Comments

@RajAsapu
Copy link

I am getting the "org.openqa.selenium.WebDriverException: Unrecognized platform: mac-unknown-64bit"

Same exception is occurring for the linux.

while running my test with phantomJs . Below are the configurations i am using
Dependencies


 compile group: 'org.jboss.arquillian.extension', name: 'arquillian-phantom-driver', version: '1.2.1.1'
 compile group: 'org.seleniumhq.selenium', name: 'selenium-server', version: '3.4.0'
 compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.4.0'

To Open browser:
try { String[] cli_args = new String[]{"--ignore-ssl-errors=true", "--debug=true"}; DesiredCapabilities capabilities = DesiredCapabilities.phantomjs(); capabilities.setJavascriptEnabled(true); capabilities.acceptInsecureCerts(); capabilities.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, cli_args); driver = new PhantomJSDriver( ResolvingPhantomJSDriverService.createDefaultService(), capabilities); } catch (IOException e) { e.printStackTrace(); } ((JavascriptExecutor) driver).executeAsyncScript( "window.setTimeout(arguments[arguments.length - 1], 30000);"); driver.manage().window().setSize(new Dimension(1280, 1024));

@barancev
Copy link
Member

Please provide the complete log that contains the exception stacktrace, we have to know where it was thrown from.

@bushee
Copy link

bushee commented Sep 29, 2017

I've just stumbled upon exactly the same problem. Here's my stacktrace (for JS app):

Driver info: driver.version: RemoteWebDriver
29-Sep-2017 14:48:47 	    at Object.checkLegacyResponse (/project/node_modules/selenium-webdriver/lib/error.js:505:15)
29-Sep-2017 14:48:47 	    at parseHttpResponse (/project/node_modules/selenium-webdriver/lib/http.js:509:13)
29-Sep-2017 14:48:47 	    at doSend.then.response (/project/node_modules/selenium-webdriver/lib/http.js:440:13)
29-Sep-2017 14:48:47 	    at <anonymous>
29-Sep-2017 14:48:47 	    at process._tickCallback (internal/process/next_tick.js:169:7)
29-Sep-2017 14:48:47 	From: Task: WebDriver.createSession()
29-Sep-2017 14:48:47 	    at Function.createSession (/project/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
29-Sep-2017 14:48:47 	    at createDriver (/project/node_modules/selenium-webdriver/index.js:167:33)
29-Sep-2017 14:48:47 	    at Builder.build (/project/node_modules/selenium-webdriver/index.js:632:14)
29-Sep-2017 14:48:47 	    at Local.getNewDriver (/project/node_modules/protractor/built/driverProviders/driverProvider.js:52:33)
29-Sep-2017 14:48:47 	    at Runner.createBrowser (/project/node_modules/protractor/built/runner.js:194:43)
29-Sep-2017 14:48:47 	    at q.then.then (/project/node_modules/protractor/built/runner.js:338:29)
29-Sep-2017 14:48:47 	    at _fulfilled (/project/node_modules/protractor/node_modules/q/q.js:834:54)
29-Sep-2017 14:48:47 	    at self.promiseDispatch.done (/project/node_modules/protractor/node_modules/q/q.js:863:30)
29-Sep-2017 14:48:47 	    at Promise.promise.promiseDispatch (/project/node_modules/protractor/node_modules/q/q.js:796:13)
29-Sep-2017 14:48:47 	    at /project/node_modules/protractor/node_modules/q/q.js:604:44

@barancev
Copy link
Member

@bushee I can't see from your log that you have the same problem ("Unrecognized platform")

@RajAsapu
Copy link
Author

RajAsapu commented Sep 29, 2017

@barancev : Below is the log

`org.openqa.selenium.WebDriverException: Unrecognized platform: mac-unknown-64bit
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'MIA-LT-13341.local', ip: 'fe80:0:0:0:488:a658:4253:2d25%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.12.6', java.version: '1.8.0_144'
Driver info: driver.version: PhantomJSDriver

	at org.openqa.selenium.Platform.fromString(Platform.java:325)
	at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:234)
	at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)
	at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:116)`

@RajAsapu
Copy link
Author

Phantom Js is working with Selenium 3.0.1 and setting the platform using

capabilities.setCapability("Platform", Platform.ANY);

instead of

capabilities.setPlatform(Platform.ANY);

@nkonev
Copy link

nkonev commented Sep 30, 2017

I have same error:

Caused by: org.openqa.selenium.WebDriverException: Unrecognized platform: linux-unknown-64bit
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T15:28:36.4Z'
System info: host: 'fedora.localdomain', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.1.10-200.fc22.x86_64', java.version: '1.8.0_121'
Driver info: driver.version: PhantomJSDriver
        at org.openqa.selenium.Platform.fromString(Platform.java:325)
        at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:234)
        at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:140)
        at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>(PhantomJSDriver.java:116)
        at com.github.nikit.cpp.selenium.SeleniumFactory.start(SeleniumFactory.java:85)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1758)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1695)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1624)
        ... 43 common frames omitted

branch if need https://github.com/nikit-cpp/blog/tree/backend-update

mcasperson added a commit to mcasperson/IridiumApplicationTesting that referenced this issue Sep 30, 2017
mcasperson added a commit to mcasperson/IridiumApplicationTesting that referenced this issue Sep 30, 2017
@mcasperson
Copy link

This is the code from RemoteWebDriver.startSession()

protected void startSession(Capabilities desiredCapabilities) {
   Map<String, ?> parameters = ImmutableMap.of("desiredCapabilities", desiredCapabilities);

   Response response = execute(DriverCommand.NEW_SESSION, parameters);

   Map<String, Object> rawCapabilities = (Map<String, Object>) response.getValue();
   MutableCapabilities returnedCapabilities = new MutableCapabilities();
   for (Map.Entry<String, Object> entry : rawCapabilities.entrySet()) {
     // Handle the platform later
     if (CapabilityType.PLATFORM.equals(entry.getKey()) || "platformName".equals(entry.getKey())) {
       continue;
     }
     returnedCapabilities.setCapability(entry.getKey(), entry.getValue());
   }
   String platformString = (String) rawCapabilities.getOrDefault(CapabilityType.PLATFORM, rawCapabilities.get("platformName"));
   Platform platform;
   try {
     if (platformString == null || "".equals(platformString)) {
       platform = Platform.ANY;
     } else {
       platform = Platform.fromString(platformString);
     }
   } catch (IllegalArgumentException e) {
     // The server probably responded with a name matching the os.name
     // system property. Try to recover and parse this.
     platform = Platform.extractFromSysProperty(platformString);
   }
   returnedCapabilities.setCapability(CapabilityType.PLATFORM, platform);
   returnedCapabilities.setCapability("platformName", platform);

   if (rawCapabilities.containsKey(SUPPORTS_JAVASCRIPT)) {
     Object raw = rawCapabilities.get(SUPPORTS_JAVASCRIPT);
     if (raw instanceof String) {
       returnedCapabilities.setCapability(SUPPORTS_JAVASCRIPT, Boolean.parseBoolean((String) raw));
     } else if (raw instanceof Boolean) {
       returnedCapabilities.setCapability(SUPPORTS_JAVASCRIPT, ((Boolean) raw).booleanValue());
     }
   } else {
     returnedCapabilities.setCapability(SUPPORTS_JAVASCRIPT, true);
   }

   capabilities = returnedCapabilities;
   sessionId = new SessionId(response.getSessionId());
 }

There are 2 issues here:

  1. PhantomJS is returning a platform like mac-unknown-64bit, linux-unknown-64bit or windows-10-32bit. None of these values will ever be parsed by Platform.fromString(), so a WebDriverException is thrown.
  2. Platform.fromString(platformString) may throw a WebDriverException, but the try block only catches a IllegalArgumentException. Hence the WebDriverException bubbles up and stops the application.

This is a dirty hack that will get you out of trouble for now:

package au.com.agic.apptesting.drivers;

import com.google.common.collect.ImmutableMap;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriverException;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DriverCommand;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.Response;

import java.lang.reflect.Field;
import java.util.Map;

import static org.openqa.selenium.remote.CapabilityType.SUPPORTS_JAVASCRIPT;

/**
 * This driver provides a work around for the bug at
 * https://github.com/SeleniumHQ/selenium/issues/4781
 */
public class PhantomJSFixedDriver extends PhantomJSDriver {
	public PhantomJSFixedDriver(Capabilities desiredCapabilities) {
		super(desiredCapabilities);
	}

	protected void startSession(Capabilities desiredCapabilities) {
		Map<String, ?> parameters = ImmutableMap.of("desiredCapabilities", desiredCapabilities);

		Response response = execute(DriverCommand.NEW_SESSION, parameters);

		Map<String, Object> rawCapabilities = (Map<String, Object>) response.getValue();
		MutableCapabilities returnedCapabilities = new MutableCapabilities();
		for (Map.Entry<String, Object> entry : rawCapabilities.entrySet()) {
			// Handle the platform later
			if (CapabilityType.PLATFORM.equals(entry.getKey()) || "platformName".equals(entry.getKey())) {
				continue;
			}
			returnedCapabilities.setCapability(entry.getKey(), entry.getValue());
		}
		String platformString = (String) rawCapabilities.getOrDefault(CapabilityType.PLATFORM, rawCapabilities.get("platformName"));
		Platform platform;
		try {
			if (platformString == null || "".equals(platformString)) {
				platform = Platform.ANY;
			} else {
				platform = Platform.fromString(platformString);
			}
		} catch (WebDriverException e) {
			/*
			 	Phantom JS returned a platform string that is not recognised. Try splitting
			 	the string to get the first part of the platform, which is the OS name.
			  */
			try {
				platform = Platform.fromString(platformString.split("-")[0]);
			} catch (IllegalArgumentException e2) {
				// The server probably responded with a name matching the os.name
				// system property. Try to recover and parse this.
				platform = Platform.extractFromSysProperty(platformString);
			}
		}
		returnedCapabilities.setCapability(CapabilityType.PLATFORM, platform);
		returnedCapabilities.setCapability("platformName", platform);

		if (rawCapabilities.containsKey(SUPPORTS_JAVASCRIPT)) {
			Object raw = rawCapabilities.get(SUPPORTS_JAVASCRIPT);
			if (raw instanceof String) {
				returnedCapabilities.setCapability(SUPPORTS_JAVASCRIPT, Boolean.parseBoolean((String) raw));
			} else if (raw instanceof Boolean) {
				returnedCapabilities.setCapability(SUPPORTS_JAVASCRIPT, ((Boolean) raw).booleanValue());
			}
		} else {
			returnedCapabilities.setCapability(SUPPORTS_JAVASCRIPT, true);
		}

		try {
			Field field = RemoteWebDriver.class.getDeclaredField("capabilities");
			field.setAccessible(true);
			field.set(this, returnedCapabilities);
		} catch (IllegalAccessException | NoSuchFieldException e) {
			throw new RuntimeException(e);
		}

		setSessionId(response.getSessionId());
	}
}

@MrEfrem
Copy link

MrEfrem commented Oct 2, 2017

I see also this error on selenium-server-standalone-3.6.0.jar. On selenium-server-standalone-3.5.3.jar it's ok.

@bushee
Copy link

bushee commented Oct 2, 2017

@barancev sorry, I just pasted stacktrace alone. Here's more error message:

build	29-Sep-2017 16:06:07	[16:06:07] E/launcher - WebDriverError: Unrecognized platform: linux-unknown-64bit
build	29-Sep-2017 16:06:07	Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-27T16:15:40.131Z'
build	29-Sep-2017 16:06:07	System info: host: '<hostname-masked>', ip: '<ip-masked>', os.name: 'Linux', os.arch: 'amd64', os.version: '3.19.0-26-generic', java.version: '1.8.0_66'
build	29-Sep-2017 16:06:07	Driver info: driver.version: RemoteWebDriver
build	29-Sep-2017 16:06:07	    at Object.checkLegacyResponse (/project/node_modules/selenium-webdriver/lib/error.js:505:15)
build	29-Sep-2017 16:06:07	    at parseHttpResponse (/project/node_modules/selenium-webdriver/lib/http.js:509:13)
build	29-Sep-2017 16:06:07	    at doSend.then.response (/project/node_modules/selenium-webdriver/lib/http.js:440:13)
build	29-Sep-2017 16:06:07	    at <anonymous>
build	29-Sep-2017 16:06:07	    at process._tickCallback (internal/process/next_tick.js:169:7)
build	29-Sep-2017 16:06:07	From: Task: WebDriver.createSession()
build	29-Sep-2017 16:06:07	    at Function.createSession (/project/node_modules/selenium-webdriver/lib/webdriver.js:777:24)
build	29-Sep-2017 16:06:07	    at createDriver (/project/node_modules/selenium-webdriver/index.js:167:33)
build	29-Sep-2017 16:06:07	    at Builder.build (/project/node_modules/selenium-webdriver/index.js:632:14)
build	29-Sep-2017 16:06:07	    at Local.getNewDriver (/project/node_modules/protractor/built/driverProviders/driverProvider.js:52:33)
build	29-Sep-2017 16:06:07	    at Runner.createBrowser (/project/node_modules/protractor/built/runner.js:194:43)
build	29-Sep-2017 16:06:07	    at q.then.then (/project/node_modules/protractor/built/runner.js:338:29)
build	29-Sep-2017 16:06:07	    at _fulfilled (/project/node_modules/protractor/node_modules/q/q.js:834:54)
build	29-Sep-2017 16:06:07	    at self.promiseDispatch.done (/project/node_modules/protractor/node_modules/q/q.js:863:30)
build	29-Sep-2017 16:06:07	    at Promise.promise.promiseDispatch (/project/node_modules/protractor/node_modules/q/q.js:796:13)
build	29-Sep-2017 16:06:07	    at /project/node_modules/protractor/node_modules/q/q.js:604:44

@ckitt
Copy link

ckitt commented Oct 2, 2017

Thanks @MrEfrem, the problems resolved after changing to version 3.5.3

@RajAsapu
Copy link
Author

RajAsapu commented Oct 2, 2017

@barancev : @MrEfrem says that it is fixed in 3.5.3 not 3.6.0, which means it has to be fixed in the latest version . I expect this issue to be open until its resolved in the latest version .

@barancev
Copy link
Member

barancev commented Oct 2, 2017

GitHub automatically closes issues mentioned as fixed in commit message. Let's keep open till the release, NP.

@gigaga
Copy link

gigaga commented Oct 3, 2017

Hi everyone,

I had the same issue whereas no change was done. I use selenium-java:3.4.0 that depends on htmlunit-driver:2.26 but htmlunit-driver:2.26 depends on selenium-api:[3.3.1,4.0.0). Since some days, selenium-api:3.4.0 was used (by transitivity) but now, selenium-api:3.6.0 is used. This release causes this issue.
My workaround is to exclude htmlunit-driver from selenium-java to avoid to download/use selenium-api:3.6.0 and continue to use selenium-api:3.4.0.

@sandeep-singh-79
Copy link

@barancev The fix provided by you works fine for now. However, could you tell us as to when would we get a release with a fix for this issue?

@akriuchk
Copy link

akriuchk commented Oct 9, 2017

I have the same issue with last version, so I use selenium-server v.3.5.1. With it all OK.

lkwg82 added a commit to lkwg82/de.lgohlke.selenium-webdriver that referenced this issue Oct 12, 2017
Hi-Fi added a commit to MarketSquare/robotframework-seleniumlibrary-java that referenced this issue Oct 18, 2017
@BullyWiiPlaza
Copy link

BullyWiiPlaza commented Oct 19, 2017

For Java the latest version 3.6.0 still has this bug so please fix it soon. So far the workaround is using version 3.5.3:

<dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-java</artifactId>
	<version>3.5.3</version>
</dependency>

See this question.

@lyt9304
Copy link

lyt9304 commented Oct 26, 2017

I fixed this problem by using 3.5.3 !!
thanks to @MrEfrem!

wakaleo added a commit to serenity-bdd/serenity-core that referenced this issue Nov 1, 2017
@barancev
Copy link
Member

barancev commented Nov 4, 2017

Fixed in version 3.7 that was released a couple of days ago.

@barancev barancev closed this as completed Nov 4, 2017
@gbuckholtz
Copy link

3.7 fixed it for me too

@ghost
Copy link

ghost commented Jan 8, 2018

after sometime 3.7 release fixed.. nice

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests