0

I'm using BASH scripts to check if Selenium is up and running before continuing with a test.

In the past for Selenium 2 I have used the below command to test if the server is up or not.

http://<<selenium_pc>>:4444/selenium-server/driver/?cmd=getLogMessages

This returns back "OK,". I use curl and store the value returned back in a variable and then just compare to see if should continue the test.

When I moved to Selenium 3 I haven't been able to find this equivalent command. What I am doing in the meantime is to use curl to get the page back and store it in a variable and then compare that against a file I saved locally and catted in to another variable for comparison.

This isn't as elegant.

I could use:

http://<<selenium_pc>>:4444/wd/hub/status

But this gives me a JSON object back that has a hCode value that always changes.

Am I missing anything obvious?

Adam

Adam
  • 350
  • 1
  • 5
  • 15

1 Answers1

0

When you invoke the URL

it gives you back this JSON

{
    "state": "success",
    "sessionId": null,
    "hCode": 1508265052,
    "value": {
        "build": {
            "version": "3.0.1",
            "revision": "1969d75",
            "time": "2016-10-18 09:48:19 -0700"
        },
        "os": {
            "name": "Mac OS X",
            "arch": "x86_64",
            "version": "10.12.1"
        },
        "java": {
            "version": "1.8.0_66"
        }
    },
    "class": "org.openqa.selenium.remote.Response",
    "status": 0
}

You should be able to easily just parse this JSON object which you get as a response and work with that no ? For e.g., from the above response you could easily parse the value of state (or) the value of status using techniques described here.

Community
  • 1
  • 1
Krishnan Mahadevan
  • 14,121
  • 6
  • 34
  • 66