Java.io.IOException : Connection was aborted by the software in your host machine with Sendkey() in selenium java exception

Java.io.IOException : Connection was aborted by the software in your host machine with Sendkey() in selenium java exception … here is a solution to the problem.

Java.io.IOException : Connection was aborted by the software in your host machine with Sendkey() in selenium java exception

Operating system: Win7 64-bit
Browser: Chrome

I’m finishing my homework to test a program with Selenium.
I’m using the code provided by the professor and it creates a web app on my localhost:8080 (so there shouldn’t be any connectivity issues).

public void canConenctTwoPlayers() {
     connect
    2: missing code
    this.indexPage.connect.click();
    assertThat(this.indexPage.hasText("Successfully connected to the game with unique "), is(true));
    this.indexPage.numberPlayers.click();
    this.indexPage.numberPlayers.sendKeys("2");
    this.indexPage.open.click();
    second connect
    ChromeDriver second_player = quickConnectAnotherUser();
    3: missing code
    assertThat(this.indexPage.hasText("The game is now ready to begin"), is(true));
     quit
    4: missing code
    disconnectSecondUser(second_player);
    this.indexPage.disconnect.click();      
}

Here numberPlayers is an element in the window that, as the name suggests, enters the number of players. But when I use sendKeys, it gives me this exception

java.io.IOException: java.util.concurrent.ExecutionException: 
java.io.IOException: Connection was aborted by the software in your host machine

When I comment out the send key, the code works fine.

2018-11-30 13:24:52.749  INFO 18632 --- [nio-8080-exec-1] c.c.poker.game.PokerSocketHandler        : Opened new session for _fc6yznc.
2018-11-30 13:24:52.749  INFO 18632 --- [nio-8080-exec-1] ca.carleton.poker.game.PokerGame         : Player is trying to connect _fc6yznc, WebSocketServerSockJsSession[id=_fc6yznc]
2018-11-30 13:24:52.749  INFO 18632 --- [nio-8080-exec-1] ca.carleton.poker.game.PokerGame         : Setting first player as admin:_fc6yznc.
2018-11-30 13:24:52.749  INFO 18632 --- [nio-8080-exec-1] ca.carleton.poker.game.PokerGame         : Player is being added _fc6yznc, WebSocketServerSockJsSession[id=_fc6yznc]
2018-11-30 13:24:52.750  INFO 18632 --- [nio-8080-exec-1] ca.carleton.poker.game.PokerGame         : Sessions WebSocketServerSockJsSession[id=_fc6yznc]
2018-11-30 13:24:52.750  INFO 18632 --- [nio-8080-exec-1] c.c.poker.game.PokerSocketHandler        : Sending admin message to player.
2018-11-30 13:24:52.750  INFO 18632 --- [nio-8080-exec-1] ca.carleton.poker.game.PokerGame         : Current number of players is 1. Required number is 4.
2018-11-30 13:24:52.872 ERROR 18632 --- [nio-8080-exec-2] c.c.poker.game.PokerSocketHandler        : TRANSPORT ERROR - Error with the network.

java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: Connection was aborted by the software in your host machine
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessageBlock(WsRemoteEndpointImplBase.java:282)
at org.apache.tomcat.websocket.WsSession.sendCloseMessage(WsSession.java:570)
at org.apache.tomcat.websocket.WsSession.onClose(WsSession.java:510)
at org.apache.tomcat.websocket.WsFrameBase.processDataControl(WsFrameBase.java:342)
at org.apache.tomcat.websocket.WsFrameBase.processData(WsFrameBase.java:284)
at org.apache.tomcat.websocket.WsFrameBase.processInputBuffer(WsFrameBase.java:130)
at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:60)
at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler$WsReadListener.onDataAvailable(WsHttpUpgradeHandler.java:203)
at org.apache.coyote.http11.upgrade.AbstractServletInputStream.onDataAvailable(AbstractServletInputStream.java:198)
at org.apache.coyote.http11.upgrade.AbstractProcessor.upgradeDispatch(AbstractProcessor.java:96)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:663)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1521)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1478)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Unknown Source)
Caused by: java.util.concurrent.ExecutionException: java.io.IOException: Connection was aborted by the software in your host machine
at org.apache.tomcat.websocket.FutureToSendHandler.get(FutureToSendHandler.java:102)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessageBlock(WsRemoteEndpointImplBase.java:275)
... 16 common frames omitted
Caused by: java.io.IOException: Connection was aborted by the software in your host machine
at sun.nio.ch.SocketDispatcher.write0(Native Method)
at sun.nio.ch.SocketDispatcher.write(Unknown Source)
at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
at sun.nio.ch.IOUtil.write(Unknown Source)
at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:127)
at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:184)
at org.apache.coyote.http11.upgrade.NioServletOutputStream.doWriteInternal(NioServletOutputStream.java:94)
at org.apache.coyote.http11.upgrade.NioServletOutputStream.doWrite(NioServletOutputStream.java:61)
at org.apache.coyote.http11.upgrade.AbstractServletOutputStream.writeInternal(AbstractServletOutputStream.java:165)
at org.apache.coyote.http11.upgrade.AbstractServletOutputStream.write(AbstractServletOutputStream.java:132)
at org.apache.tomcat.websocket.server.WsRemoteEndpointImplServer.onWritePossible(WsRemoteEndpointImplServer.java:98)
at org.apache.tomcat.websocket.server.WsRemoteEndpointImplServer.doWrite(WsRemoteEndpointImplServer.java:80)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.writeMessagePart(WsRemoteEndpointImplBase.java:450)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessage(WsRemoteEndpointImplBase.java:338)
at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.startMessageBlock(WsRemoteEndpointImplBase.java:270)
... 16 common frames omitted

2018-11-30 13:24:52.872  INFO 18632 --- [nio-8080-exec-2] c.c.poker.game.PokerSocketHandler        : Closing session for _fc6yznc with status CloseStatus[code=1000, reason=null].
2018-11-30 13:24:52.872  INFO 18632 --- [nio-8080-exec-2] c.c.poker.game.PokerSocketHandler        : Disabling all accounts because the admin left.
2018-11-30 13:24:52.873  INFO 18632 --- [nio-8080-exec-2] ca.carleton.poker.game.PokerGame         : Sessions WebSocketServerSockJsSession[id=_fc6yznc]
2018-11-30 13:24:52.873  INFO 18632 --- [nio-8080-exec-2] c.carleton.poker.session.SessionHandler  : Registered _fc6yznc for disconnect.

Solution

This error message….

java.io.IOException: java.util.concurrent.ExecutionException: 
java.io.IOException: Connection was aborted by the software in your host machine

… Imply that the exception is caused by concurrent execution.

According to the discussion, ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine with GeckoDriver and Firefox when you try in This problem occurs when sendKeys() is called JavaScript when calling sendKeys(/ jQuery is still active.

Solution

The solution is to introduce WebDriverWait/ for JavaScript jQuery use ExpectedConditions Any one to finish:

Related Problems and Solutions