Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key Error Status using remote webdriver #1332

Closed
daviwesley opened this issue Jul 15, 2021 · 3 comments
Closed

Key Error Status using remote webdriver #1332

daviwesley opened this issue Jul 15, 2021 · 3 comments

Comments

@daviwesley
Copy link

🐛 Bug Report

I'm trying to connect to a remote web browser that is contained on a docker image but I keep receive Key Error: 'status'

Traceback (most recent call last):
  File "/Users/daviwesley/Documents/selenium-teste/teste.py", line 8, in <module>
    driver = webdriver.Remote(
  File "/Users/daviwesley/.local/share/virtualenvs/selenium-teste-WkmCj9Zh/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/Users/daviwesley/.local/share/virtualenvs/selenium-teste-WkmCj9Zh/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/Users/daviwesley/.local/share/virtualenvs/selenium-teste-WkmCj9Zh/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
    self.error_handler.check_response(response)
  File "/Users/daviwesley/.local/share/virtualenvs/selenium-teste-WkmCj9Zh/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 130, in check_response
    status = value["status"]
KeyError: 'status'

Docker logs

13:30:35.911 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "b3178fbaced4c4d64730ddfee96c15ac","spanId": "b5f202ef567e1c79","spanKind": "INTERNAL","eventTime": 1626355835821414211,"eventName": "exception","attributes": {"driver.url": "http:\u002f\u002flocalhost:4059","exception.message": "Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.\n (chrome not reachable)\n (The process started from chrome location \u002fusr\u002fbin\u002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\nBuild info: version: '4.0.0-beta-3', revision: '909239cd9f'\nSystem info: host: 'c4578c827a10', ip: '172.21.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '1.8.0_282'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: unknown error: Chrome failed to start: crashed.\n (chrome not reachable)\n (The process started from chrome location \u002fusr\u002fbin\u002fgoogle-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)\nBuild info: version: '4.0.0-beta-3', revision: '909239cd9f'\nSystem info: host: 'c4578c827a10', ip: '172.21.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '1.8.0_282'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:116)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:60)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:325)\n\tat org.openqa.selenium.grid.node.NewNodeSession.execute(NewNodeSession.java:52)\n\tat org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:192)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.security.RequiresSecretFilter.lambda$apply$0(RequiresSecretFilter.java:64)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\n\tat java.lang.Thread.run(Thread.java:748)\n","exception.type": "org.openqa.selenium.SessionNotCreatedException","logger": "org.openqa.selenium.grid.node.config.DriverServiceSessionFactory","session.capabilities": "{\"browserName\": \"chrome\",\"version\": \"\"}\n"}}

To Reproduce

  1. docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210713
  2. execute test script

Expected behavior

A successful connection with the remote selenium

Test script reproducing this issue (when applicable)

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

host = 'http://localhost:4444/wd/hub'
options = webdriver.ChromeOptions()

driver = webdriver.Remote(
    command_executor=host,
    desired_capabilities=DesiredCapabilities.CHROME, 
)

Environment

OS: OSX 11.4
Docker-Selenium image version: selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210713
-->
Docker version 20.10.7, build f0df350

@ghost ghost added the needs-triaging label Jul 15, 2021
@mspiessch
Copy link

Same issue running it with docker-compose

Bug report

I'm trying to connect to a remote web browser that is contained on a docker image but I keep receive Key Error: 'status'

Expected behavior

A successful connection with the remote selenium

To Reproduce

  • docker-compose up -d - ok
  • run test script - fail

Logs files

shell output error

Traceback (most recent call last):
  File "/app/project/tests/__init__.py", line 9, in setUp
    self.browser = webdriver.Remote(
  File "/opt/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/opt/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/opt/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/opt/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 130, in check_response
    status = value["status"]
KeyError: 'status'

selenium hub docker container

{
   "traceId":"8a959195b27555f5bb2779d48c63a170",
   "eventTime":1626555129793509544,
   "eventName":"HTTP request execution complete",
   "attributes":{
      "http.flavor":1,
      "http.handler_class":"org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue",
      "http.host":"192.168.144.2:4444",
      "http.method":"POST",
      "http.request_content_length":"210",
      "http.scheme":"HTTP",
      "http.status_code":500,
      "http.target":"\u002fsession",
      "http.user_agent":"selenium\u002f3.141.0 (python linux)"
   }
}

selenium node firefox docker container

{
   "traceId":"8a959195b27555f5bb2779d48c63a170",
   "eventTime":1626555129660825168,
   "eventName":"exception",
   "attributes":{
      "driver.url":"http:\u002f\u002flocalhost:20244",
      "exception.message":"Error while creating session with the driver service. Stopping driver service: Could not start a new session. Response code 500. Message: Process unexpectedly closed with status 11\nBuild info: version: '4.0.0-rc-1', revision: '74745cf081'\nSystem info: host: '4790491a0bf5', ip: '192.168.144.4', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown",
      "exception.stacktrace":"org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Response code 500. Message: Process unexpectedly closed with status 11\nBuild info: version: '4.0.0-rc-1', revision: '74745cf081'\nSystem info: host: '4790491a0bf5', ip: '192.168.144.4', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.25-linuxkit', java.version: '11.0.11'\nDriver info: driver.version: unknown\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:126)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:84)\n\tat org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:62)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:129)\n\tat org.openqa.selenium.grid.node.config.DriverServiceSessionFactory.apply(DriverServiceSessionFactory.java:63)\n\tat org.openqa.selenium.grid.node.local.SessionSlot.apply(SessionSlot.java:143)\n\tat org.openqa.selenium.grid.node.local.LocalNode.newSession(LocalNode.java:312)\n\tat org.openqa.selenium.grid.node.NewNodeSession.execute(NewNodeSession.java:52)\n\tat org.openqa.selenium.remote.http.Route$TemplatizedRoute.handle(Route.java:192)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.security.RequiresSecretFilter.lambda$apply$0(RequiresSecretFilter.java:64)\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\n\tat java.base\u002fjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)\n\tat java.base\u002fjava.util.concurrent.FutureTask.run(FutureTask.java:264)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)\n\tat java.base\u002fjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)\n\tat java.base\u002fjava.lang.Thread.run(Thread.java:829)\n",
      "exception.type":"org.openqa.selenium.SessionNotCreatedException",
      "logger":"org.openqa.selenium.grid.node.config.DriverServiceSessionFactory",
      "session.capabilities":"{\"acceptInsecureCerts\": true,\"browserName\": \"firefox\",\"se:vncEnabled\": true}\n"
   }
}

test code

import unittest
from selenium import webdriver

class FunctionalBaseTest(unittest.TestCase):

    def setUp(self):
        selenium_url = "http://selenium-hub:4444/wd/hub"
        options = webdriver.FirefoxOptions()
        capabilities = webdriver.DesiredCapabilities.FIREFOX.copy()
        self.browser = webdriver.Remote(
            command_executor=selenium_url,
            options=options,
            desired_capabilities=capabilities
        )

    def test_site_homepage_is_runnign(self):
        self.browser.get('http://localhost')
        self.assertIn('Django', self.browser.title)
        self.browser.close()
    
    def tearDown(self):
        self.browser.quit()

docker-compose

# Selenium Services
    firefox:
        image: selenium/node-firefox:4
        container_name: selenium_grid_firefox_api
        shm_size: 2gb
        depends_on:
          - selenium-hub
        environment:
          - SE_EVENT_BUS_HOST=selenium-hub
          - SE_EVENT_BUS_PUBLISH_PORT=4442
          - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
        ports:
          - "6900:5900"
        networks: 
            - vlan
    
    selenium-hub:
        image: selenium/hub:4
        container_name: selenium_grid_hub
        ports:
          - "4442:4442"
          - "4443:4443"
          - "4444:4444"
        networks: 
            - vlan

Environment

System Version: macOS 11.4 (20F71)
Docker version: 20.10.7, build f0df350
Docker Image: selenium/node-firefox:4
Docker Image: selenium/hub:4
MacBookAir M1

@Yuya-Furusawa
Copy link

Similar issue here!
I posted this issue on Selenium Group(but no answers yet).
https://groups.google.com/g/selenium-users/c/KVv-svSGSH8

shell output error

% docker-compose exec app python src/example.py
Traceback (most recent call last):
  File "src/example.py", line 13, in <module>
    options=options,
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 130, in check_response
    status = value["status"]
KeyError: 'status'

Directory Structure:

Desktop
└── selenium_example
             ├── docker-compose.yml
             ├── Dockerfile
             ├── requirements.txt
             └── src
                 └── example.py

Dockerfile

FROM python:3.9-slim
ENV PYTHONIOENCODING utf-8
RUN mkdir -p /app
WORKDIR /app
COPY ./requirements.txt ./requirements.txt
RUN pip install -r requirements.txt

docker-compose.yml

version: "3"
services:
  selenium:
    image: selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210618
    ports:
      - 4444:4444
      - 5900:5900
    shm_size: "2gb"
  app:
    build: .
    volumes:
      - /path/to/Desktop/selenium_example:/app
    tty: true

requirements.txt

selenium

example.py

from selenium import webdriver

if __name__ == '__main__':
  options = webdriver.ChromeOptions()
  options.add_argument('--headless')
  driver = webdriver.Remote(
    command_executor="http://selenium:4444/wd/hub",
    desired_capabilities=options.to_capabilities(),
    options=options,
  )
  driver.get("https://google.com")
  print(driver.current_url)

  driver.quit()

Extra Info:

macOS Big Sur(version 11.4)
Apple M1

% docker version
Client:
 Cloud integration: 1.0.17
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.16.4
 Git commit:        f0df350
 Built:             Wed Jun  2 11:56:23 2021
 OS/Arch:           darwin/arm64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:55:36 2021
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
% docker-compose exec app pip list
Package    Version
---------- -------
pip        21.1.2
selenium   3.141.0
setuptools 57.0.0
urllib3    1.26.6
wheel      0.36.2

@diemol
Copy link
Member

diemol commented Jul 30, 2021

Sadly we do not support M1/ARM yet, please follow #1076 for updates.

@diemol diemol closed this as completed Jul 30, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants