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
5,316 views

2 answers to this question.

+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
• 69,220 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,370 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

+1 vote
2 answers

Python with Selenium issue: “Chrome is being controlled by automated test software”

from selenium import webdriver chrome_options = webdriver.ChromeOptions() chrome_options.add_experimental_option("useAutomationExtension", False) chrome_options.add_experimental_option("excludeSwitches",["enable-automation"]) driver ...READ MORE

answered Apr 20, 2020 in Selenium by Manoj
15,898 views
+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 28, 2018 in Selenium by nsv999
• 5,500 points
27,378 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,500 points

edited Apr 4, 2018 by nsv999 7,447 views
0 votes
2 answers

How to use Selenium with Python?

Hey Shubham, you can checkout this thread ...READ MORE

answered Aug 26, 2019 in Selenium by Abha
• 28,140 points
1,199 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,910 points
2,755 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
• 780 points
41,838 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
• 780 points
4,882 views
+10 votes
17 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,360 points
197,977 views
+1 vote
2 answers

How to click button selenium python?

Have you tried using implicit_wait method before getting ...READ MORE

answered May 27, 2019 in Selenium by Abha
• 28,140 points
10,412 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP