While executing script it will launch URL in emulator and rest of line are not executing in karate framework - karate

When i executing script it will launch URL"www.google.com" in emulator and rest of line are not executing.
"Please suggest me the solution" Is this way to write elements?
Environment details:
JDK 1.8
Appium v1.17
Node js v12.18
Andriod stuido v4
Feature file:
Feature: Testing Mobile
Scenario: launch chrome in appium
* configure driver =
"""
{
type: 'android',
webDriverPath : "/wd/hub",
start: true,
httpConfig : { readTimeout: 120000 }
}
"""
* def desiredConfig =
"""
{
"newCommandTimeout" : 300,
"platformVersion" : "10.0",
"platformName" : "Android",
"connectHardwareKeyboard" : true,
"deviceName" : "emulator-5554",
"avd" : "Pixel_2_API_29",
"automationName" : "UiAutomator2",
"browserName" : "Chrome" ,
"chromedriverExecutable" : "C:/Users/abc/Downloads/chromedriver_win32_2/chromedriver.exe"
}
"""
* driver { webDriverSession: { desiredCapabilities : "#(desiredConfig)"} }
* driver 'http://google.com'
And delay(4000)
* driver click("//a[text()='Images']")
# driver.input("//input[#name='q']", 'karate dsl')
Logs in console:
10:31:16.654 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [HTTP] --> POST /wd/hub
/session/3b12fd81-db3b-421e-8218-b94c1ed331b5/element
10:31:16.695 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [HTTP] {"using":"xpath","value":"//a[text()
='Images']"}
10:31:16.698 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [MJSONWP (3b12fd81)] Calling AppiumDrive
r.findElement() with args: ["xpath","//a[text()='Images']","3b12fd81-db3b-421e-8218-b94c1ed331b5"]
10:31:16.699 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [BaseDriver] Valid locator strategies fo
r this request: xpath, id, class name, accessibility id, -android uiautomator
10:31:16.702 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [BaseDriver] Waiting up to 0 ms for cond
ition
10:31:16.703 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [WD Proxy] Matched '/element' to command
name 'findElement'
10:31:16.706 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [WD Proxy] Proxying [POST /element] to [
POST http://127.0.0.1:8203/wd/hub/session/600582cc-a05b-422e-b886-7daeff02de45/element] with body: {"strategy":"xpath","selector":"//a[text()='Images']","context":"","multiple":false}
10:31:17.466 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [WD Proxy] Got response with status 404: {"sessi
onId":"600582cc-a05b-422e-b886-7daeff02de45","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:102)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:51)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCon...
10:31:17.467 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [W3C] Matched W3C error code 'no such el
ement' to NoSuchElementError
10:31:17.474 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 823.75
5 < 500
5 < Connection: keep-alive
5 < Content-Length: 164
5 < Content-Type: application/json; charset=utf-8
5 < Date: Wed, 01 Jul 2020 05:01:17 GMT
5 < ETag: W/"a4-/qNMwkKiq6QWZf9aZdImFcg10wM"
5 < Vary: X-HTTP-Method-Override
5 < X-Powered-By: Express
{"status":7,"value":{"message":"An element could not be located on the page using the given search parameters."},"sessionId":"3b12fd81-db3b-421e-8218-b94c1ed331b5"}
10:31:17.478 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [MJSONWP (3b12fd81)] Encountered interna
l error running command: NoSuchElementError: An element could not be located on the page using the given search parameters.
10:31:17.484 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [MJSONWP (3b12fd81)] at AndroidUiaut
omator2Driver.findElOrEls (C:\Users\M1058955\AppData\Roaming\npm\node_modules\appium\node_modules\appium-android-driver\lib\commands\find.js:75:11)
10:31:17.484 [ForkJoinPool-1-worker-1] WARN com.intuit.karate - http response code: 500, response: {"sessionId":"3b12fd81-db3b-421e-8218-b94c1ed331b5","value":{"message":"An element could not be located on the page using the given search parameters."},"status":7}, request: [method: POST, responseTime: 823.7536, body: {"using":"xpath","value":"//a[text()='Images']"}]
10:31:17.484 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [HTTP] <-- POST /wd/hub/session/3b12fd81-db
3b-421e-8218-b94c1ed331b5/element 500 819 ms - 164
10:31:17.484 [ForkJoinPool-1-worker-1] WARN c.i.k.driver.android_1593579654225 - locator failed, will retry once: {"sessionId":"3b12fd81-db3b-421e-8218-b94c1ed331b5","value":{"message":"An element could not be located on the page using the given search parameters."},"status":7}
10:31:17.485 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [HTTP]
10:31:20.490 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - request:
6 > POST http://localhost:50636/wd/hub/session/3b12fd81-db3b-421e-8218-b94c1ed331b5/element
6 > Accept-Encoding: gzip,deflate
6 > Connection: Keep-Alive
6 > Content-Length: 48
6 > Content-Type: application/json; charset=UTF-8
6 > Host: localhost:50636
6 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_181)
{"using":"xpath","value":"//a[text()='Images']"}
10:31:20.531 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [HTTP] --> POST /wd/hub
/session/3b12fd81-db3b-421e-8218-b94c1ed331b5/element
10:31:20.532 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [HTTP] {"using":"xpath","value":"//a[text()
='Images']"}
10:31:20.533 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [MJSONWP (3b12fd81)] Calling AppiumDrive
r.findElement() with args: ["xpath","//a[text()='Images']","3b12fd81-db3b-421e-8218-b94c1ed331b5"]
10:31:20.534 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [BaseDriver] Valid locator strategies fo
r this request: xpath, id, class name, accessibility id, -android uiautomator
10:31:20.535 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [BaseDriver] Waiting up to 0 ms for cond
ition
10:31:20.536 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [WD Proxy] Matched '/element' to command
name 'findElement'
10:31:20.536 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [WD Proxy] Proxying [POST /element] to [
POST http://127.0.0.1:8203/wd/hub/session/600582cc-a05b-422e-b886-7daeff02de45/element] with body: {"strategy":"xpath","selector":"//a[text()='Images']","context":"","multiple":false}
10:31:21.026 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [WD Proxy] Got response with status 404: {"sessi
onId":"600582cc-a05b-422e-b886-7daeff02de45","value":{"error":"no such element","message":"An element could not be located on the page using the given search parameters","stacktrace":"io.appium.uiautomator2.common.exceptions.ElementNotFoundException: An element could not be located on the page using the given search parameters\n\tat io.appium.uiautomator2.handler.FindElement.findElement(FindElement.java:102)\n\tat io.appium.uiautomator2.handler.FindElement.safeHandle(FindElement.java:72)\n\tat io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:38)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:252)\n\tat io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:242)\n\tat io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:51)\n\tat io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)\n\tat io.netty.channel.AbstractChannelHandlerCon...
10:31:21.027 [android_1593579654225] DEBUG c.i.k.driver.android_1593579654225 - [debug] [W3C] Matched W3C error code 'no such el
ement' to NoSuchElementError
10:31:21.028 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 498.60
6 < 500

can you please try karate version 0.9.6.RC3 ?, maybe based on you location Images locator might be changing?
xpath
Given driver 'https://www.google.com'
Then waitForUrl('https://www.google.com')
And click("//a[text()='Images']")
And input("//input[#name='q']", 'karate dsl')
should work with this version of karate and appium 1.17.1.

Related

TestContainer Rabbitmq seems to release connection as soon as it is start

I am using testcontainers in a spring boot project (version : 1.17.2) and I am trying to spin up a rabbitmq container. It seems like rabbitmq container starts up successfully, but it releases connection as soon as it is up.
I can see some error in logs but after that I can see that the test container is started. I am kind of flummoxed as to why am I seeing this error and/or if the container is started or not ?
Pasting excerpt from logs :
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_management_agent
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_web_dispatch
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_management
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> * rabbitmq_prometheus
15:00:44.007 [main] DEBUG org.testcontainers.containers.output.WaitingConsumer - STDOUT: 2022-06-29 05:00:24.477316+00:00 [info] <0.703.0> Server startup complete; 4 plugins started.
15:00:44.007 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-0000000C: cancel
15:00:44.007 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.DefaultManagedHttpClientConnection - http-outgoing-1: close connection IMMEDIATE
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-0000000C: endpoint closed
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.InternalHttpClient - ep-0000000C: discarding endpoint
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-0000000C: releasing endpoint
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-0000000C: connection is not kept alive
15:00:44.008 [docker-java-stream--540868428] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire - http-outgoing-1 << "end of stream"
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManager - ep-0000000C: connection released [route: {}->npipe://localhost:2375][total available: 0; route allocated: 0 of 2147483647; total allocated: 0 of 2147483647]
15:00:44.008 [main] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire - http-outgoing-1 << "[read] I/O error: java.nio.channels.ClosedChannelException"
15:00:44.008 [docker-java-stream--540868428] DEBUG com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.wire - http-outgoing-1 << "[read] I/O error: java.nio.channels.ClosedChannelException"
15:00:44.008 [docker-java-stream--540868428] DEBUG com.github.dockerjava.zerodep.ApacheDockerHttpClientImpl$ApacheResponse - Failed to close the response
java.io.IOException: java.nio.channels.ClosedChannelException
at java.base/java.nio.channels.Channels$2.read(Channels.java:240)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.io.LoggingInputStream.read(LoggingInputStream.java:81)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.fillBuffer(SessionInputBufferImpl.java:149)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.SessionInputBufferImpl.readLine(SessionInputBufferImpl.java:280)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.getChunkSize(ChunkedInputStream.java:261)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.nextChunk(ChunkedInputStream.java:222)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.read(ChunkedInputStream.java:147)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.ChunkedInputStream.close(ChunkedInputStream.java:314)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.io.Closer.close(Closer.java:48)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.impl.io.IncomingHttpEntity.close(IncomingHttpEntity.java:111)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.io.entity.HttpEntityWrapper.close(HttpEntityWrapper.java:120)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.io.Closer.close(Closer.java:48)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.message.BasicClassicHttpResponse.close(BasicClassicHttpResponse.java:93)
at com.github.dockerjava.zerodep.shaded.org.apache.hc.client5.http.impl.classic.CloseableHttpResponse.close(CloseableHttpResponse.java:200)
at com.github.dockerjava.zerodep.ApacheDockerHttpClientImpl$ApacheResponse.close(ApacheDockerHttpClientImpl.java:256)
at org.testcontainers.shaded.com.github.dockerjava.core.DefaultInvocationBuilder.lambda$executeAndStream$1(DefaultInvocationBuilder.java:277)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.nio.channels.ClosedChannelException: null
....................................
15:00:44.009 [main] INFO 🐳 [rabbitmq:3.9.13-management-alpine] - Container rabbitmq:3.9.13-management-alpine started in PT7.8752359S
Config Java :
public abstract class RabbitMqTestContainerConfiguration {
private static final int RABBITMQ_DEFAULT_PORT = 5672;
#Container
public static RabbitMQContainer rabbitMQContainer = new RabbitMQContainer("rabbitmq:3.9.13-management-alpine")
.withExposedPorts(RABBITMQ_DEFAULT_PORT).withStartupTimeout(Duration.ofMinutes(3));
public static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> {
#Override
public void initialize(ConfigurableApplicationContext configurableApplicationContext) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(configurableApplicationContext,
"spring.rabbitmq.host=" + rabbitMQContainer.getHost(),
"spring.rabbitmq.port=" + rabbitMQContainer.getMappedPort(RABBITMQ_DEFAULT_PORT),
"spring.rabbitmq.username=" + rabbitMQContainer.getAdminUsername(),
"spring.rabbitmq.password=" + rabbitMQContainer.getAdminPassword());
}
}
} ```

Getting error as "karate.org.apache.http.conn.HttpHostConnectException" while running test cases on Karate

First Case: On Local Eclipse
Issue: While running test cases on Karate, I am getting below error where
Feature file as below:
Background:
* configure driver = { type: 'chrome', start: false, showDriverLog: true }
Scenario: Verify
Given driver 'https://www.google.com/'
And input('input[name=q]', 'karate-dsl')
Console error as below:
15:14:30.630 [main] ERROR com.intuit.karate - karate.org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused), http call failed after 4 milliseconds for url: http://localhost:9222/json
15:14:32.636 [main] DEBUG com.intuit.karate - request:
1 > GET http://localhost:9222/json
1 > Host: localhost:9222
1 > Connection: Keep-Alive
1 > User-Agent: Apache-HttpClient/4.5.13 (Java/1.8.0_321)
1 > Accept-Encoding: gzip,deflate
15:14:32.638 [main] ERROR com.intuit.karate - karate.org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1, localhost/0:0:0:0:0:0:0:1] failed: Connection refused (Connection refused), http call failed after 3 milliseconds for url: http://localhost:9222/json
15:14:32.640 [main] ERROR com.intuit.karate - driver config / start failed: http call failed after 3 milliseconds for url: http://localhost:9222/json, options: {type=chrome, start=false, showDriverLog=true, target=null}
com.intuit.karate.KarateException: http call failed after 3 milliseconds for url: http://localhost:9222/json
If we make a change in driver config as below as it is hitting the native chrome. It starts to work fine,
configure driver = { type: 'chrome', start: true, showDriverLog: true }
Second Case: On Docker Image, "https://hub.docker.com/r/ptrthomas/karate-chrome", if driver config change as below:
configure driver = { type: 'chrome', start: true, showDriverLog: true }
Getting the same above error on docker image.
Is it supposed to config differently for local and docker image or I am missing something. Can some one please help ?

How to invoke Android emulator by using feature file in Karate Framework

Am going to open Google URL in emulator when execute feature file in karate framework.
But i getting test case is failed due to following reason:
17:49:10.459 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.android_1593087505311 - poll attempt #20
for port to be ready - localhost:58674
17:49:13.452 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - request:
1 > POST http://localhost:58674/session
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 58
1 > Content-Type: application/json; charset=UTF-8
1 > Host: localhost:58674
1 > User-Agent: Apache-HttpClient/4.5.12 (Java/1.8.0_181)
{"capabilities":{"alwaysMatch":{"browserName":"android"}}}
"Please provide me solution"
Pre-condition: Appium Server and emulator is running. and below is feature file.
Feature: Mobile automation
Background:
* url 'http://localhost:4723/wd/hub'
* configure driver = { type: 'android' }
* def driverCaps = {"browserName": "chrome","newCommandTimeout":180, "platformVersion": "8.0",
"platformName": "Android","deviceName":"emulator-5554", "avd":"Nexus 6P API 26"}
Scenario: Perform additional operation
Given driver 'https://google.com'
And input("input[name=q]", 'karate dsl')
When submit().click("input[name=btnI]")
# this may fail depending on which part of the world you are in !
Then waitForUrl('https://github.com/intuit/karate')
your driverCaps is unused as you have defined it after configure,
using the below snippet I was able to launch a chrome browser in Android Emulator.
Scenario: launch chrome in appium
* configure driver =
"""
{
type: 'android',
webDriverPath : "/wd/hub",
start: true,
httpConfig : { readTimeout: 120000 }
}
"""
* def desiredConfig =
"""
{
"newCommandTimeout" : 300,
"platformVersion" : "9.0",
"platformName" : "Android",
"connectHardwareKeyboard" : true,
"deviceName" : "emulator-5554",
"avd" : "Pixel2",
"automationName" : "UiAutomator2",
"browserName" : "Chrome"
}
"""
* driver { webDriverSession: { desiredCapabilities : "#(desiredConfig)"} }
* driver 'http://google.com'
* driver.input("//input[#name='q']", 'karate dsl')
Note:
if you are facing any chrome driver issue please refer : chromedriver with Appium
currently only xpath locator are working so try with xpath locators

NightwatchJS /geckodriver/ selenoid: Error retrieving a new session from the selenium server, while executing test on Firefox,

Setup Information:
OS - MacOS HighSierra - 10.13.3
DockerCE for Mac - 17.12.0-ce-mac49
Selenoid, Selenoid-ui - Latest
Firefox - 58, geckodriver - 0.191 (0.190,0.170)
Chrome - 63, ChromeDriver 2.34.522932
Selenium standalone server - 3.9.1
On Local setup the test runs successsfully with Firefox and Chrome
using the same geckodriver.
On Remote setup the test fails while I use Firefox and succeeds using Chrome.
Verbose log from NightwatchJS
Prasannas-MacBook-Air:sim1 prvenkat$ ./node_modules/nightwatch/bin/nightwatch ./src/test/login.js --verbose
[Test / Login] Test Suite
=============================
Running: Validate Login page
INFO Request: POST /wd/hub/session
- data: {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","moz:firefoxOptions":{"log":{"level":"trace"}},"version":"57.0","name":"Test / Login"}}
- headers: {"Content-Type":"application/json; charset=utf-8","Content-Length":199}
INFO Response 200 POST /wd/hub/session (3439ms) { value:
{ sessionId: '43ba7a2a-8fac-4ebb-8a8f-e046e5534944',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '57.0',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 37,
'moz:profile': '/tmp/rust_mozprofile.i3MIoxBzkGAM',
'moz:webdriverClick': false,
pageLoadStrategy: 'normal',
platformName: 'linux',
platformVersion: '4.9.60-linuxkit-aufs',
rotatable: false,
timeouts: { implicit: 0, pageLoad: 300000, script: 30000 } } } }
Error retrieving a new session from the selenium server
Connection refused! Is selenium server started?
{ value:
{ sessionId: '43ba7a2a-8fac-4ebb-8a8f-e046e5534944',
capabilities:
{ acceptInsecureCerts: false,
browserName: 'firefox',
browserVersion: '57.0',
'moz:accessibilityChecks': false,
'moz:headless': false,
'moz:processID': 37,
'moz:profile': '/tmp/rust_mozprofile.i3MIoxBzkGAM',
'moz:webdriverClick': false,
pageLoadStrategy: 'normal',
platformName: 'linux',
platformVersion: '4.9.60-linuxkit-aufs',
rotatable: false,
timeouts: [Object] } } }
Trace log from the Docker container
Initialize...
Connecting to ws://localhost:8080/ws/logs/43ba7a2a-8fac-4ebb-8a8f-e046e5534944...
Connected!
--- x11vnc loop: 1 ---
2018/02/22 05:20:47 Loading configuration files...
2018/02/22 05:20:47 Loaded configuration from [/etc/selenoid/browsers.json]
2018/02/22 05:20:47 Using default containers log configuration because of:read error: open config/container-logs.json: no such file or directory
2018/02/22 05:20:47 Timezone: UTC
2018/02/22 05:20:47 Listening on :4444
2018/02/22 05:20:47 [NEW_REQUEST]
2018/02/22 05:20:47 [NEW_REQUEST_ACCEPTED]
2018/02/22 05:20:47 [0] [LOCATING_SERVICE] [firefox-57.0]
2018/02/22 05:20:47 [0] [USING_DRIVER] [firefox-57.0]
2018/02/22 05:20:47 [0] [ALLOCATING_PORT]
2018/02/22 05:20:47 [0] [ALLOCATED_PORT] [41809]
2018/02/22 05:20:47 [0] [STARTING_PROCESS] [[/usr/bin/geckodriver --host :: --log debug --port=41809]]
1519276847981 geckodriver INFO geckodriver 0.19.1
1519276847981 webdriver::httpapi DEBUG Creating routes
1519276847986 geckodriver INFO Listening on [::]:41809
1519276848032 webdriver::server DEBUG -> HEAD /
1519276848160 webdriver::server DEBUG <- 404 Not Found {"value":{"error":"unknown command","message":"HEAD / did not match a known command","stacktrace":"stack backtrace:\n 0: 0x4edb3c - backtrace::backtrace::trace::hc4bd56a2f176de7e\n 1: 0x4edb72 - backtrace::capture::Backtrace::new::he3b2a15d39027c46\n 2: 0x440ac8 - webdriver::error::WebDriverError::new::ha0fbd6d1a1131b43\n 3: 0x43a665 - <webdriver::server::HttpHandler<U> as hyper::server::Handler>::handle::h343049f2e1aa3f13\n 4: 0x404b4d - std::sys_common::backtrace::__rust_begin_short_backtrace::he840f14c79c8e321\n 5: 0x40bee6 - std::panicking::try::do_call::hdd1d6b985699ef9d\n 6: 0x5e6a6c - panic_unwind::__rust_maybe_catch_panic\n at /checkout/src/libpanic_unwind/lib.rs:99\n 7: 0x41ef02 - <F as alloc::boxed::FnBox<A>>::call_box::hae8ac6ade91dedb6\n 8: 0x5df13b - alloc::boxed::{{impl}}::call_once<(),()>\n at /checkout/src/liballoc/boxed.rs:692\n - std::sys_common::thread::start_thread\n at /checkout/src/libstd/sys_common/thread.rs:21\n - std::sys::imp::thread::{{impl}}::new::thread_start\n at /checkout/src/libstd/sys/unix/thread.rs:84"}}
2018/02/22 05:20:48 [0] [PROCESS_STARTED] [32] [181.491408ms]
2018/02/22 05:20:48 [0] [PROXYING_REQUESTS] [http://127.0.0.1:41809]
2018/02/22 05:20:48 [0] [SESSION_ATTEMPTED] [unknown] [http://127.0.0.1:41809] [1]
1519276848161 webdriver::server DEBUG -> POST /session {"desiredCapabilities":{"browserName":"firefox","javascriptEnabled":true,"acceptSslCerts":true,"platform":"ANY","moz:firefoxOptions":{"log":{"level":"trace"}},"version":"57.0","name":"Test / Login"}}
1519276848167 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.i3MIoxBzkGAM"
1519276848171 geckodriver::marionette TRACE connection attempt 0/600
1519276848271 geckodriver::marionette TRACE connection attempt 1/600
--- x11vnc loop: waiting for: 61
1519276848372 geckodriver::marionette TRACE connection attempt 2/600
PORT=5900
1519276848474 geckodriver::marionette TRACE connection attempt 3/600
1519276848575 geckodriver::marionette TRACE connection attempt 4/600
1519276848677 geckodriver::marionette TRACE connection attempt 5/600
1519276848694 Marionette DEBUG Received observer notification "profile-after-change"
1519276848755 Marionette DEBUG Received observer notification "command-line-startup"
1519276848756 Marionette INFO Enabled via --marionette
1519276848778 geckodriver::marionette TRACE connection attempt 6/600
1519276848880 geckodriver::marionette TRACE connection attempt 7/600
1519276848980 geckodriver::marionette TRACE connection attempt 8/600
1519276849081 geckodriver::marionette TRACE connection attempt 9/600
1519276849183 geckodriver::marionette TRACE connection attempt 10/600
1519276849285 geckodriver::marionette TRACE connection attempt 11/600
1519276849386 geckodriver::marionette TRACE connection attempt 12/600
1519276849487 geckodriver::marionette TRACE connection attempt 13/600
1519276849589 geckodriver::marionette TRACE connection attempt 14/600
1519276849690 geckodriver::marionette TRACE connection attempt 15/600
1519276849792 geckodriver::marionette TRACE connection attempt 16/600
1519276849894 geckodriver::marionette TRACE connection attempt 17/600
1519276849930 Marionette DEBUG Received observer notification "sessionstore-windows-restored"
1519276849996 geckodriver::marionette TRACE connection attempt 18/600
1519276850097 geckodriver::marionette TRACE connection attempt 19/600
1519276850197 geckodriver::marionette TRACE connection attempt 20/600
1519276850298 geckodriver::marionette TRACE connection attempt 21/600
1519276850399 geckodriver::marionette TRACE connection attempt 22/600
1519276850499 geckodriver::marionette TRACE connection attempt 23/600
1519276850600 geckodriver::marionette TRACE connection attempt 24/600
1519276850679 Marionette DEBUG Setting recommended pref toolkit.cosmeticAnimations.enabled to false
1519276850681 Marionette DEBUG Setting recommended pref datareporting.policy.dataSubmissionPolicyAccepted to false
1519276850681 Marionette DEBUG Setting recommended pref extensions.e10sBlocksEnabling to false
1519276850682 Marionette DEBUG New connections are accepted
1519276850683 Marionette INFO Listening on port 37569
1519276850702 geckodriver::marionette DEBUG Connected to Marionette onlocalhost:37569
1519276850712 Marionette DEBUG Accepted connection 0 from 127.0.0.1:42836
1519276850714 geckodriver::marionette TRACE <- {"applicationType":"gecko","marionetteProtocol":3}
1519276850714 geckodriver::marionette TRACE -> 315:[0,1,"newSession",{"acceptSslCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptSslCerts":true,"browserName":"firefox","javascriptEnabled":true,"name":"Test / Login","platform":"ANY","version":"57.0"}},"javascriptEnabled":true,"name":"Test / Login","platform":"ANY","version":"57.0"}]
1519276850717 Marionette TRACE 0 -> [0,1,"newSession",{"acceptSslCerts":true,"browserName":"firefox","capabilities":{"desiredCapabilities":{"acceptSslCerts":true,"browserName":"firefox","javascriptEnabled":true,"name":"Test / Login","platform":"ANY","version":"57.0"}},"javascriptEnabled":true,"name":"Test / Login","platform":"ANY","version":"57.0"}]
1519276850783 Marionette DEBUG Register listener.js for window 2147483649
1519276850806 Marionette TRACE 0 <- [1,1,null,{"sessionId":"43ba7a2a-8fac-4ebb-8a8f-e046e5534944","capabilities":{"browserName":"firefox","browserVersion":"57.0","platformName":"linux","platformVersion":"4.9.60-linuxkit-aufs","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":37,"moz:profile":"/tmp/rust_mozprofile.i3MIoxBzkGAM","moz:webdriverClick":false}}]
1519276850809 geckodriver::marionette TRACE <- [1,1,null,{"sessionId":"43ba7a2a-8fac-4ebb-8a8f-e046e5534944","capabilities":{"browserName":"firefox","browserVersion":"57.0","platformName":"linux","platformVersion":"4.9.60-linuxkit-aufs","pageLoadStrategy":"normal","acceptInsecureCerts":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"rotatable":false,"moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":37,"moz:profile":"/tmp/rust_mozprofile.i3MIoxBzkGAM","moz:webdriverClick":false}}]
1519276850809 webdriver::server DEBUG <- 200 OK {"value": {"sessionId":"43ba7a2a-8fac-4ebb-8a8f-e046e5534944","capabilities":{"acceptInsecureCerts":false,"browserName":"firefox","browserVersion":"57.0","moz:accessibilityChecks":false,"moz:headless":false,"moz:processID":37,"moz:profile":"/tmp/rust_mozprofile.i3MIoxBzkGAM","moz:webdriverClick":false,"pageLoadStrategy":"normal","platformName":"linux","platformVersion":"4.9.60-linuxkit-aufs","rotatable":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000}}}}
2018/02/22 05:20:50 [0] [SESSION_CREATED] [unknown] [43ba7a2a-8fac-4ebb-8a8f-e046e5534944] [http://127.0.0.1:41809] [1] [2.832759113s]
2018/02/22 05:21:50 [SESSION_DELETED] [43ba7a2a-8fac-4ebb-8a8f-e046e5534944]
1519276910817 webdriver::server DEBUG -> DELETE /session/43ba7a2a-8fac-4ebb-8a8f-e046e5534944
1519276910819 geckodriver::marionette TRACE -> 37:[0,2,"quit",{"flags":["eForceQuit"]}]
1519276910827 Marionette TRACE 0 -> [0,2,"quit",{"flags":["eForceQuit"]}]
1519276910830 Marionette DEBUG New connections will no longer be accepted
1519276910973 Marionette TRACE 0 <- [1,2,null,{"cause":"shutdown"}]
1519276911015 geckodriver::marionette TRACE <- [1,2,null,{"cause":"shutdown"}]
1519276911015 webdriver::server DEBUG Deleting session
1519276911015 geckodriver::marionette DEBUG Stopping browser process
1519276911077 webdriver::server DEBUG <- 200 OK {"value": {}}
2018/02/22 05:21:51 [0] [TERMINATING_PROCESS] [32]
2018/02/22 05:21:51 [0] [TERMINATED_PROCESS] [32]
Disconnected
I had tested the scenario with three different geckodriver but the result was same.
Please help.
The error says it all :
1519276847986 geckodriver INFO Listening on [::]:41809
1519276848032 webdriver::server DEBUG -> HEAD /
1519276848160 webdriver::server DEBUG <- 404 Not Found {"value":{"error":"unknown command","message":"HEAD / did not match a known command","stacktrace":"stack backtrace:\n 0: 0x4edb3c - backtrace::backtrace::trace::hc4bd56a2f176de7e\n 1: 0x4edb72 - backtrace::capture::Backtrace::new::he3b2a15d39027c46\n 2: 0x440ac8 - webdriver::error::WebDriverError::new::ha0fbd6d1a1131b43\n 3: 0x43a665 - <webdriver::server::HttpHandler<U> as hyper::server::Handler>::handle::h343049f2e1aa3f13\n 4: 0x404b4d - std::sys_common::backtrace::__rust_begin_short_backtrace::he840f14c79c8e321\n 5: 0x40bee6 - std::panicking::try::do_call::hdd1d6b985699ef9d\n 6: 0x5e6a6c - panic_unwind::__rust_maybe_catch_panic\n at /checkout/src/libpanic_unwind/lib.rs:99\n 7: 0x41ef02 - <F as alloc::boxed::FnBox<A>>::call_box::hae8ac6ade91dedb6\n 8: 0x5df13b - alloc::boxed::{{impl}}::call_once<(),()>\n at /checkout/src/liballoc/boxed.rs:692\n - std::sys_common::thread::start_thread\n at /checkout/src/libstd/sys_common/thread.rs:21\n - std::sys::imp::thread::{{impl}}::new::thread_start\n at /checkout/src/libstd/sys/unix/thread.rs:84"}}
Due to this issue the SESSION gets DELETED as follows :
2018/02/22 05:20:50 [0] [SESSION_CREATED] [unknown] [43ba7a2a-8fac-4ebb-8a8f-e046e5534944] [http://127.0.0.1:41809] [1] [2.832759113s]
2018/02/22 05:21:50 [SESSION_DELETED] [43ba7a2a-8fac-4ebb-8a8f-e046e5534944]
The error stack trace clearly mentions that Selenium Language Binding Art is attempting to connect on the IPv6 loopback address ([::]:41809), which won't work at all with 3.9.x as per #JimEvans comment in the discussion thread Can't launch Selenium IE Driver after upgrading to version 3.9
Solution
A possible solution would be to disable IPv6 loopback address and enable IPv4 on the Remote setup and execute your Test.
Have a look here:
https://github.com/nightwatchjs/nightwatch/issues/1628#issuecomment-357746215
That means you will have to fallback to 3.8 and a selenium Grid setup.

click link without ID or Class with casperJS

I'm trying to get the list of links on the menu on the left on this page: http://www.hpenterprisesecurity.com/vulncat
the first thing I'm trying to do is click the "Expand All" link (on the top left corner) so the list gets expanded.
I have tried multiple ways to use the Xpath in different ways with no success on this page, this was my last try:
casper.start('http://www.hpenterprisesecurity.com/vulncat', function() {
casper.wait(5000);
this.echo("---------- TITLE: ");
this.echo(this.getTitle());
});
casper.thenClick(x('//*[#id="theContentCenter"]/div/p/a[1]/strong[contains(text(),"Expand")]'),function(){
casper.wait(5000,function(){
casper.capture("expanded.png");
});
});
Maybe since the page lacks Ids and Tags for most elements my approach won't work?
Thanks
the set-up:
casper = require('casper').create({
verbose:true,
logLevel:"debug"
});
casper.userAgent('Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405');
casper.viewport = {width: 1280, height: 720};
var x = require('casper').selectXPath;
phantomjs: 1.9.8
casperjs: 1.1.0-beta3
RESOURCE ERROR:
[info] [phantom] Starting...
[info] [phantom] Running suite: 2 steps
[info] [phantom] Starting...
[info] [phantom] Running suite: 4 steps
[debug] [phantom] opening url: http://www.hpenterprisesecurity.com/vulncat, HTTP GET
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html, type=Other, willNavigate=true, isMainFrame=true
[debug] [phantom] url changed to "http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html"
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/header.html, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/all.html, type=Other, willNavigate=true, isMainFrame=false
[debug] [phantom] Navigation requested: url=http://www.hpenterprisesecurity.com/vulncat/en/vulncat/intro.html, type=Other, willNavigate=true, isMainFrame=false
ResourceError: {
"errorCode": 203,
"errorString": "Error downloading http://www.hpenterprisesecurity.com/vulncat/en/vulncat/css/frame.css - server replied: Not Found",
"id": 7,
"url": "http://www.hpenterprisesecurity.com/vulncat/en/vulncat/css/frame.css"
}
ResourceError: {
"errorCode": 2,
"errorString": "Connection closed",
"id": 9,
"url": "http://www.fortifysoftware.com/images/gui/maincontent.level3.h1.bg.png"
}
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Step anonymous 2/4 http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html (HTTP 200)
---------- TITLE:
A Taxonomy of Coding Errors that Affect Security
[info] [phantom] Step anonymous 2/4: done in 770ms.
[info] [phantom] Step _step 3/5 http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html (HTTP 200)
[info] [phantom] Step _step 3/5: done in 770ms.
[info] [phantom] wait() finished waiting for 5000ms.
[info] [phantom] Step _step 4/5 http://www.hpenterprisesecurity.com/vulncat/en/vulncat/index.html (HTTP 200)
[debug] [phantom] Mouse event 'mousedown' on selector: xpath selector: //*[#id="theContentCenter"]/div/p/a[1]/strong[contains(text(),"Expand")]
CasperError: Cannot dispatch mousedown event on nonexistent selector: xpath selector: //*[#id="theContentCenter"]/div/p/a[1]/strong[contains(text(),"Expand")]
/usr/lib/node_modules/casperjs/modules/casper.js:1355 in mouseEvent
/usr/lib/node_modules/casperjs/modules/casper.js:462 in click
/usr/lib/node_modules/casperjs/modules/casper.js:1793 in _step
/usr/lib/node_modules/casperjs/modules/casper.js:1553 in runStep
/usr/lib/node_modules/casperjs/modules/casper.js:399 in checkStep
Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match.
Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match.
Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///usr/lib/node_modules/casperjs/bin/bootstrap.js. Domains, protocols and ports must match.