This question already has an answer here:
I managed to get chrome driver downloaded using WebDriverManager however I cannot figured out why this error is appearing.
I have heard to use the chrome driver available in the EC2 instances however I'm unsure how to retrieve. Any help regarding this error or a different solution would be greatly appreciated.
Error
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Nov 15, 2019 8:40:15 AM java.util.prefs.FileSystemPreferences$1 run
WARNING: Couldn't create user preferences directory. User preferences are unusable.
Nov 15, 2019 8:40:15 AM java.util.prefs.FileSystemPreferences$1 run
WARNING: java.io.IOException: No such file or directory
/tmp/chromedriver /*This is me detecting the chrome driver was downloaded*/
Starting ChromeDriver 78.0.3904.70 (edb9c9f3de0247fd912a77b7f6cae7447f6d3ad5-refs/branch-heads/3904@{#800}) on port 1804
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1573807217.600][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807217.938][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807217.989][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.040][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.091][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.141][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.192][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.243][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.294][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.345][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.396][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.447][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.497][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.548][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.599][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.650][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.701][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.752][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.802][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.853][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.904][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
[1573807218.955][SEVERE]: CreatePlatformSocket() failed: Address family not supported by protocol (97)
unknown error: Chrome failed to start: exited abnormally
(chrome not reachable)
(The process started from chrome location /tmp/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '169.254.215.13', ip: '169.254.215.13', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.133-97.112.amzn2.x86_64', java.version: '1.8.0_201'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x5602458297e9 <unknown>
: org.openqa.selenium.WebDriverException
org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
(chrome not reachable)
(The process started from chrome location /tmp/chromedriver is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: '169.254.215.13', ip: '169.254.215.13', os.name: 'Linux', os.arch: 'amd64', os.version: '4.14.133-97.112.amzn2.x86_64', java.version: '1.8.0_201'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x5602458297e9 <unknown>
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62)
at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
at com.test.org.test.ChromeDriverController.<init>(ChromeDriverController.java:132)
at com.test.org.test.OrgCreate.handleRequest(OrgCreate.java:12)
at com.test.org.test.OrgCreate.handleRequest(OrgCreate.java:1)
Code
WebDriverManager.chromedriver()
.targetPath("/"+fileName)
.setup();
File file = new File("/"+fileName+"/user-data");
file.mkdirs();
file = new File("/"+fileName+"/data-path");
file.mkdirs();
file = new File("/"+fileName+"/cache-dir");
file.mkdirs();
loopFile(tmp);
ChromeOptions options = new ChromeOptions();
options.setBinary("/tmp/chromedriver");
options.addArguments(
"no-sandbox",
"--disable-gpu",
"--enable-javascript",
"--disable-dev-shm-usage",
"--disable-extensions",
"--headless",
"--single-process",
"--enable-logging",
"--v=99",
"--remote-debugging-port=45447",
"--user-data-dir=/"+fileName+"/user-data",
"--data-path=/"+fileName+"/data-path",
"--homedir=/"+fileName,
"--disk-cache-dir=/"+fileName+"/cache-dir",
"window-size=1400,600",
"log-level=3");
this.driver = (WebDriver) new ChromeDriver(options);
this.driver.manage().deleteAllCookies();
Edit:
Duplicate is not related. This needs an answer relating to the AWS service as the driver cannot be placed outside the tmp folder.