selenium-python Process unexpectedly closed with status 1

+1 vote

I am using Python 2.7 with selenium 3. I am  using selenium grid for web automation. When I am starting selenium server as hub and registering node with server manually running on terminal works fine.

But when same commands ran in background using python script or shell script I am seeing error "Process unexpectedly closed with status 1"

For registering a node i am using command in background as:

nohup java -jar selenium-server-standalone-3.14.0.jar -role node -hub http://192.168.57.29:5555/grid/register &
I can see process running but automation fails with above error message

Sep 27, 2018 in Selenium by paragf
• 160 points
99 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+1 vote
Best answer

Hi paragf! I checked your code.

 Firstly, there seems to a syntax error at:

output = os.system(cmd))

this line should be:

output = os.system(cmd)

But this wouldn't be the cause for error.

I used the following to start the hub and register the node:

Code to start selenium hub on VM:

import os

def start_selenium_hub_on_vm():

   cmd = "java -jar selenium-server-standalone-3.10.0.jar -role hub -port 4444"

   output = os.system(cmd)
   print 'executing command ', cmd
   if output:
      return output
   else:
      return -1

start_selenium_hub_on_vm()

The output when I run this code is as folllows:

On your node, before trying to register it to the hub, make sure you have a config.json file. The config.json file should look something like this:

{
  "capabilities":
  [
    {
      "browserName": "firefox",
      "marionette": true,
      "maxInstances": 5,
      "seleniumProtocol": "WebDriver",
      "version": "62.0" //Your browser version
    }
  ],
  "proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
  "maxSession": 5,
  "port": 5555, //Port on which the hub is running
  "register": true,
  "registerCycle": 5000,
  "hub": "http://192.168.111.132:5555", //URL displayed for Node to register when you start the hub
  "nodeStatusCheckTimeout": 5000,
  "nodePolling": 5000,
  "role": "node",
  "unregisterIfStillDownAfter": 60000,
  "downPollingLimit": 2,
  "debug": false,
  "servlets" : [],
  "withoutServlets": [],
  "custom": {}
}

The python script to register node to hub:

import os
def register_node_to_hub():

   cmd = "java -jar selenium-server-standalone-3.10.0.jar -role node -nodeConfig config.json"

   output = os.system(cmd)
   print 'executing command ', cmd
   if output:
      return output
   else:
      return -1

register_node_to_hub()

The output I get: 

The error you are getting is usually got because of incompatible version. The version that successfully worked for me:

Firefox: 62.0

geckodriver-v0.19.1

selenium-server-standalone-3.10.0.jar

Python 2.7.15

Reference: https://www.linode.com/docs/development/nodejs/install-configure-selenium-grid-ubuntu-16-04/ 

answered Sep 28, 2018 by Omkar
• 65,850 points

selected Sep 28, 2018 by Omkar
0 votes

Hey paragf! Could you please share the python/shell script you are using?

answered Sep 27, 2018 by slayer
• 29,040 points
for starting selenium hub:
def start_selenium_hub_on_vm():

   cmd = "nohup java -jar /usr/local/bin/selenium-server-standalone-3.14.0.jar -port 5555 -role hub & \n"

   output = os.system(cmd))
   print 'executing command ', cmd
   if output:
      return output
   else:
      return -1


----------------------------
To register selenium server on node 
def register_selenium_node_with_hub(ip, user='admin',passwd ='admin123'):

    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(ip, username=user, password=passwd)
    command = "nohup java -jar selenium-server-standalone-3.14.0.jar -role node -hub http://192.168.57.29:5555/grid/register &"
    stdin_, stdout_, stderr_ = ssh.exec_command(command)
    lines = stdout_.readlines()
    for line in lines:
        print line
    ssh.close()
Hi,

Any update on this?

Hey there, I've posted my answer here for this problem. Please check this and let me know if it works for you. And if you've got any other solution, you can post it :-)

Related Questions In Selenium

+2 votes
2 answers

How can I press ENTER key with the execute_script in selenium python?

The below code containing Keys.ENTER might just ...READ MORE

answered Mar 27, 2018 in Selenium by nsv999
• 5,030 points
4,004 views
0 votes
1 answer

Selenium IDE (2.9.1.1-signed) not working with latest Version of Firefox

Unfortunately, Selenium IDE will be deprecated soon. ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,030 points

edited Apr 4, 2018 by nsv999 2,158 views
0 votes
1 answer

How to use Selenium with Python?

There are many resources for selenium - ...READ MORE

answered Mar 30, 2018 in Selenium by nsv999
• 5,030 points
120 views
0 votes
1 answer
0 votes
1 answer

How to login a forum using Selenium with Python

You should try to directly log in ...READ MORE

answered Apr 27, 2018 in Selenium by Samarpit
• 5,130 points
157 views
+2 votes
1 answer

I want the console.log output from Chrome. I'm working with selenium on Python

So this is how you do it ...READ MORE

answered May 3, 2018 in Selenium by sniffy_god
• 760 points
5,376 views
0 votes
1 answer

Need to select an IFrame with selenium (python)

Well for me, something like this worked. ...READ MORE

answered May 3, 2018 in Selenium by sniffy_god
• 760 points
553 views
0 votes
1 answer

How can we use Selenium with Python?

First  Install Python based on the Operating ...READ MORE

answered May 7, 2018 in Selenium by Meci Matt
• 9,400 points
38 views
+9 votes
13 answers

How to automate gmail login process using selenium webdriver in java?

Check the below code: Here is the working ...READ MORE

answered Apr 24, 2018 in Selenium by Vardy
• 2,280 points
36,157 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.