I am trying to run a test suite using selenium grid, and I was able to establish hub and one node. After this, when I am initializing the RemoteWebdiver(url, caps) call, it is throwing an exception:
org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Failed to connect to <IP>:<PORT>
Also when I ping to that "Node_IP", it shows 100% loss. But my grid console shows it is connected. I have added inbound and outbound rules for the port: 4444 through firewall. telnet command also fails for "Node_IP" and "PORT" which is "4444".
I can execute the tests in my local when I pass the URL as : http://localhost:4444/wd/hub
/**** Added Description *****/
hubConfig: java -jar selenium-server-standalone-3.13.0.jar -role hub -host "Host_IP"
nodeConfig: java -Dwebdriver.chrome.driver="chrome_driver_location_on_node" -jar selenium-server-standalone-3.13.0.jar -role node -hub http://"host_ip":4444/grid/register -browser
"browserName=chrome,platform=WINDOWS,version=67.0,maxInstances=5"
Same goes for FireFox and IE.
Code works fine as I am able to execute as a localhost.
The stacktrace is as:
FYI: "Node_PORT" is a random port. I have not assigned it. I also tried it by assigning a port but it didn't work too.
org.openqa.selenium.WebDriverException: Error forwarding the new session Error forwarding the request Failed to connect to /<Node_IP>:<Node_PORT>
Command duration or timeout: 51.98 seconds
Build info: version: '3.13.0', revision: '2f0d292', time: '2018-06-25T15:24:21.231Z'
System info: host: '<System_Info>', ip: <Hub_IP>, os.name: 'Windows Server 2008 R2', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_151'
Driver info: driver.version: RemoteWebDriver
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$new$0(JsonWireProtocolResponse.java:53)
at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$getResponseFunction$2(JsonWireProtocolResponse.java:91)
at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:123)
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:126)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Error forwarding the request Failed to connect to /<Node_IP>:<Node_PORT>
at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:118)
at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:86)
at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:860)
at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:535)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:143)
at org.seleniumhq.jetty9.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:190)
at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:188)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1253)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:168)
at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:473)
at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1564)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:166)
at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1155)
at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.seleniumhq.jetty9.server.Server.handle(Server.java:530)
at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:347)
at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:256)
at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:102)
at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
at org.seleniumhq.jetty9.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)
at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)
at java.lang.Thread.run(Unknown Source)
I got the solution for my own query and it was a very simple one which I was aware of earlier but didn't gave any second thoughts for that.
Basically, I had to start the node with a specific port and I whitelisted that port number from the security groups.
Thanks again everyone who took an effort for answering. Hope this helps those who are stuck in a similar situation.
Related
I have two grid setup's
Local grid setup (hub and nodes are running in my local machine) and my local machine connected to network#1
VM grid setup (hub and nodes are running in my virtual machine) and my virtual machine connected to network#2
When I execute the scripts I need to pass the IP address as a parameter. Here,
I can run my scripts successfully in local machine(code is available in local machine) by passing the network#1 IP address but if I pass the network#2 IP address (VM IP address) to local machine then I am getting below exception,
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
As per my knowledge, hub and nodes should be connected to same network. Cannot we run the scripts by passing the VM IP address to local machine?
Trace:
org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '3.153.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'LGN9T1X2', ip: '30.289.34.76', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_45'
Driver info: driver.version: Driver
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:573)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at driver.Driver.loginCPSUI(Driver.java:94)
Caused by: java.net.ConnectException: Failed to connect to /30.173.46.174:4444
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:165)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
at okhttp3.RealCall.execute(RealCall.java:77)
at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:105)
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.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.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
at driver.Driver.loginCPSUI(Driver.java:94)
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:497)
at io.cucumber.java.Invoker.doInvoke(Invoker.java:66)
at io.cucumber.java.Invoker.invoke(Invoker.java:24)
at io.cucumber.java.AbstractGlueDefinition.invokeMethod(AbstractGlueDefinition.java:47)
at io.cucumber.java.JavaHookDefinition.execute(JavaHookDefinition.java:59)
at io.cucumber.core.runner.CoreHookDefinition.execute(CoreHookDefinition.java:46)
at io.cucumber.core.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:21)
at io.cucumber.core.runner.ExecutionMode$1.execute(ExecutionMode.java:10)
at io.cucumber.core.runner.TestStep.executeStep(TestStep.java:92)
at io.cucumber.core.runner.TestStep.run(TestStep.java:64)
at io.cucumber.core.runner.TestCase.run(TestCase.java:98)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:71)
at io.cucumber.junit.PickleRunners$WithStepDescriptions.run(PickleRunners.java:110)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:135)
at io.cucumber.junit.FeatureRunner.runChild(FeatureRunner.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at io.cucumber.junit.Cucumber.runChild(Cucumber.java:199)
at io.cucumber.junit.Cucumber.runChild(Cucumber.java:90)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at io.cucumber.junit.Cucumber$RunCucumber.evaluate(Cucumber.java:234)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(DualStackPlainSocketImpl.java:85)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)
Yes, the exception occurred due to firewall. The ping test is successful from local machine to VM but not from VM to local. I contacted the organization network administrator and confirmed this.
I use Katalon Studio 7.0.4 and Windows Application Driver v1.2 RC and allowed port 4723 on firewall. I used PuTTY for testing. Connection is successful, application is shown in spy tool, but got errors when try to use some methods(e.g.:click, getText). I see following errors in logs.
On server side:
==========================================
GET /session/3A8AB5F8-E6B3-4FB1-9C14-E48B8F4F5C4D/screenshot HTTP/1.1
Accept-Encoding: gzip
Cache-Control: no-cache
Connection: Keep-Alive
Host: myip:4723
User-Agent: selenium/3.141.59 (java windows)
HTTP/1.1 500 Internal Error
Content-Length: 133
Content-Type: application/json
{"status":13,"value":{"error":"unknown error","message":"An unknown error occurred in the remote end while processing the command."}}
==========================================
GET /session/3A8AB5F8-E6B3-4FB1-9C14-E48B8F4F5C4D/window_handle HTTP/1.1
Accept-Encoding: gzip
Cache-Control: no-cache
Connection: Keep-Alive
Host: myip:4723
User-Agent: selenium/3.141.59 (java windows)
HTTP/1.1 200 OK
Content-Length: 84
Content-Type: application/json
{"sessionId":"3A8AB5F8-E6B3-4FB1-9C14-E48B8F4F5C4D","status":0,"value":"0x000A09F4"}
On client side:
org.openqa.selenium.WebDriverException: An unknown error occurred in
the remote end while processing the command. (WARNING: The server did
not provide any stacktrace information) Command duration or timeout: 0
milliseconds Build info: version: ‘3.141.59’, revision: ‘e82be7d358’,
time: ‘2018-11-14T08:25:53’ System info: host: ‘LAPTOP’, ip:
‘192.168.56.1’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version:
‘10.0’, java.version: ‘1.8.0_181’ Driver info:
io.appium.java_client.windows.WindowsDriver Capabilities {app:
C:\Users\user101\Downloads…, javascriptEnabled: true, platform:
WINDOWS, platformName: WINDOWS} Session ID:
3A8AB5F8-E6B3-4FB1-9C14-E48B8F4F5C4D 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.ErrorHandler.createThrowable(ErrorHandler.java:214)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at
org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at
org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at
org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
at
io.appium.java_client.remote.AppiumCommandExecutor.execute(AppiumCommandExecutor.java:239)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
at
io.appium.java_client.DefaultGenericMobileDriver.execute(DefaultGenericMobileDriver.java:46)
at io.appium.java_client.AppiumDriver.execute(AppiumDriver.java:1) at
io.appium.java_client.windows.WindowsDriver.execute(WindowsDriver.java:1)
at
org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:295)
at
com.kms.katalon.composer.windows.spy.WindowsInspectorController.captureScreenshot(WindowsInspectorController.java:82)
at
com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog$3.captureImage(WindowsRecorderDialog.java:653)
at
com.kms.katalon.composer.windows.dialog.WindowsRecorderDialog$3.run(WindowsRecorderDialog.java:620)
at
org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
In Katalon Studio:
I am trying to run my selenium automation tests on safari but I am facing an issue running through Jenkins.
I have a osX env running on a vm and running the tests locally everything is working fine. Its when I try to run these tests through Jenkins that I run into issues. They run but they are unable to open safari.
Im not very familiar with macs so dont really know whats causing the issue. The vm is a slave of jenkins and everything seems ok there.
Thanks for any help.
The error i am seeing is as follows
System info: host: 'Test-MacBook-Pro.local', ip:
'fe80:0:0:0:1c75:5215:5f4d:cef2%en0', os.name: 'Mac OS X', os.arch:
'x86_64', os.version: '10.13.4', java.version: '1.8.0_171'
Driver info: driver.version: SafariDriver
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:91)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:637)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:250)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:236)
at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:137)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:60)
at org.openqa.selenium.safari.SafariDriver.<init>(SafariDriver.java:40)
at extra.StartupTestCase.cleanUpLogin(StartupTestCase.java:292)
at extra.StartupTestCase.beforeSuite(StartupTestCase.java:197)
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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:523)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:224)
at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:146)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:326)
at org.testng.SuiteRunner.run(SuiteRunner.java:289)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
at org.testng.TestNG.runSuites(TestNG.java:1144)
at org.testng.TestNG.run(TestNG.java:1115)
at org.testng.TestNG.privateMain(TestNG.java:1442)
at org.testng.TestNG.main(TestNG.java:1411)
Caused by: org.apache.http.conn.HttpHostConnectException: Connect to localhost:16788 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:359)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:381)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:72)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
at org.openqa.selenium.remote.internal.ApacheHttpClient.fallBackExecute(ApacheHttpClient.java:139)
at org.openqa.selenium.remote.internal.ApacheHttpClient.execute(ApacheHttpClient.java:87)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:343)
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:159)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:142)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
... 26 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.socket.PlainConnectionSocketFactory.connectSocket(PlainConnectionSocketFactory.java:75)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 41 more
Looking at the error log it seems you haven't set Safari driver for Selenium.
Find out the latest safari driver for Selenium and set it's path in your code.
Running selenium code from Jenkins:
I would suggest you to use a jenkins node and trigger your java code on node.
Also you may like to use Gradle/Maven/TestNG as trigger and build.
I have faced the same error a couple of times. It seems to be a problem with the way you connect to jenkins. When you define a node in jenkins there is the option Launch method. Depending on the launch method you use behavour changes a little bit.
Probably you are using the Launch agents via SSH, which allows you to permanently connect certain machine with certain Node. However, this method runs processes in the background. For some reason, safari does not work with background processes.
Another method is the Launch agent via Java Web Start. With this option, each time you restart your machine you will have to manually connect it to the jenkins node through a Java applet. However with this method processes are launched on the front and lets you launch safari from jenkins.
I have not found a way to connect through SSH and launch safari correctly, nor I have seen any other solution.
Hope this is your issue!
I am trying invoke IE browser using Selenium Webdriver and have used the below code to invoke:
System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
driver = new InternetExplorerDriver();
But while execution I am getting error as below:
Started InternetExplorerDriver server (64-bit)
3.4.0.0
Listening on port 3210
Only local connections are allowed
Dec 12, 2017 6:29:04 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Dec 12, 2017 6:29:07 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Dec 12, 2017 6:29:07 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Exception in thread "pool-1-thread-1" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities = Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}], required capabilities = Capabilities [{}]
Build info: version: '2.42.2', revision: '6a6995d31c7c56c340d6f45a76976d43506cd6cc', time: '2014-06-03 10:52:47'
System info: host: 'PCXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_141'
Driver info: driver.version: InternetExplorerDriver
at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:91)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:141)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:82)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:241)
at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:227)
at org.openqa.selenium.ie.InternetExplorerDriver.run(InternetExplorerDriver.java:180)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:172)
at org.openqa.selenium.ie.InternetExplorerDriver.<init>(InternetExplorerDriver.java:144)
at com.cognizant.framework.selenium.WebDriverFactory.getWebDriver(WebDriverFactory.java:76)
at supportlibraries.DriverScript.initializeWebDriver(DriverScript.java:301)
at supportlibraries.DriverScript.driveTestExecution(DriverScript.java:155)
at allocator.ParallelRunner.run(ParallelRunner.java:48)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Please let me know if there is some additional settings that I have missed. System IE browser version: 11
Open Internet Options, select 'Security' Tab. Check that 'EACH' zone (Internet, Local Intranet, Trusted Sites, Restricted Sites) has 'Enable Protected Mode' enabled. This will likely require an IE restart.
You might be missing "\" in the path
try
System.setProperty("webdriver.ie.driver", driverPath+"\IEDriverServer.exe");
driver = new InternetExplorerDriver();
Try with the below options
Change the Web driver opened IE browser zoom to 100%
Navigate to Internet Options -> Security and unselect Enable protect mode for all the zones
I'm running several tests via selenium remote webdriver on remote machine. For each test i will be rebooting the VM and then restart the browser. For the first case browser launch is successful but on other iterations browser launch fails. However if i start another selenium server with different port, then second test gets executed with the new port.
Not sure why the first port couldn't be reused for the second time ?
Error is showing as below:-
ERROR in invoking Selenium Commands:Could not start a new session.
Possible causes are invalid address of the remote server or browser
start-up failure.
System info: host: 'N/A', ip: 'N/A', os.name: 'Linux', os.arch:
'i386', java.version:
'1.8.0_31'
Driver info: driver.version: RemoteWebDriver
capabilities.setCapability("platformVersion", "40.0.2");
capabilities.setCapability("platformName", "WINDOWS");
capabilities.setCapability("browserName", "firefox");
driver= new RemoteWebDriver(new URL("http://"+ipaddress+":"+portNumber+"/wd/hub"), capabilities);
Selenium server launched in VM as java -jar selenium-server.2.42.2.jar