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

[🐛 Bug]: selenium.common.exceptions.WebDriverException: Message: <empty> #2285

Closed
tamis-laan opened this issue Jun 22, 2024 · 10 comments
Closed

Comments

@tamis-laan
Copy link

What happened?

I'm trying to run the selenium helm chart and connecting using python:

hub:
  image:
    repository: selenium/hub
    tag: 4.22.0
  service:
    type: LoadBalancer

videoRecorder:
  enabled: true

chromeNode:
  replicas: 2
  image:
    repository: selenium/node-chrome
    tag: 4.22.0

firefoxNode:
  enabled: false

edgeNode:
  enabled: false

ingress:
  enabled: false
# Configure Chrome options for headless mode
chrome_options = Options()
# chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_argument("--window-size=1920x1080")
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--disable-notifications")
chrome_options.add_argument("--disable-popup-blocking")
chrome_options.add_argument("--disable-features=Notification")

# Allow microphone and webcam
chrome_options.add_experimental_option("prefs", {
    "profile.default_content_setting_values.media_stream_mic": 2,
    "profile.default_content_setting_values.media_stream_camera": 2,
    "profile.default_content_setting_values.geolocation": 2,
    "profile.default_content_setting_values.notifications": 2,
    "profile.default_content_setting_values.popups": 2,
    "profile.default_content_setting_values.automatic_downloads": 2
})

# Create a new instance of the Chrome driver
# driver = webdriver.Chrome(options=chrome_options)
driver = webdriver.Remote(
    command_executor="http://selenium-grid-selenium-hub.default.svc.cluster.local:4444/wd/hub",
    options=chrome_options
)

But I get the following error:

      > [test-6f444dfcc7-85wrl test] Traceback (most recent call last):
      > [test-6f444dfcc7-85wrl test]   File "/app/main.py", line 33, in <module>
      > [test-6f444dfcc7-85wrl test]     driver = webdriver.Remote(
      > [test-6f444dfcc7-85wrl test]              ^^^^^^^^^^^^^^^^^
      > [test-6f444dfcc7-85wrl test]   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
      > [test-6f444dfcc7-85wrl test]     self.start_session(capabilities)
      > [test-6f444dfcc7-85wrl test]   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
      > [test-6f444dfcc7-85wrl test]     response = self.execute(Command.NEW_SESSION, caps)["value"]
      > [test-6f444dfcc7-85wrl test]                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      > [test-6f444dfcc7-85wrl test]   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
      > [test-6f444dfcc7-85wrl test]     self.error_handler.check_response(response)
      > [test-6f444dfcc7-85wrl test]   File "/usr/local/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
      > [test-6f444dfcc7-85wrl test]     raise exception_class(value)
      > [test-6f444dfcc7-85wrl test] selenium.common.exceptions.WebDriverException: Message:

The error message non descriptive as the it's empty.

Command used to start Selenium Grid with Docker (or Kubernetes)

#! /bin/bash

# Add docker-selenium helm repository
helm repo add docker-selenium https://www.selenium.dev/docker-selenium

# Make sure system is running properly
kubectl wait --for=condition=Ready pods --all --namespace=kube-system --timeout=300s

# Install basic grid latest version
helm upgrade --install selenium-grid docker-selenium/selenium-grid \
	-f values.yaml

Relevant log output

No logs are produced by selenium hub

Operating System

Minikube

Docker Selenium version (image tag)

4.22.0

Selenium Grid chart version (chart version)

No response

Copy link

@tamis-laan, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@VietND96
Copy link
Member

VietND96 commented Jun 22, 2024

When helm install (upgrade) successfully, a note displays with the Hub URL that can be accessed from outside. What is it?
Also, may I know if these values worked with the previous chart version?

@tamis-laan
Copy link
Author

tamis-laan commented Jun 22, 2024

@VietND96

"docker-selenium" already exists with the same configuration, skipping
pod/etcd-minikube condition met
pod/kube-apiserver-minikube condition met
pod/kube-controller-manager-minikube condition met
pod/kube-scheduler-minikube condition met
pod/storage-provisioner condition met
Release "selenium-grid" does not exist. Installing it now.
NAME: selenium-grid
LAST DEPLOYED: Sat Jun 22 20:17:29 2024
NAMESPACE: default
STATUS: deployed
REVISION: 1
TEST SUITE: None
NOTES:
Selenium Grid Server deployed successfully.
    export POD_NAME=$(kubectl get pods -n default -l "app.kubernetes.io/name=selenium-grid-selenium-hub,app.kubernetes.io/instance=selenium-grid" -o jsonpath="{.items[0].metadata.name}")
    echo "Point your WebDriver tests to http://localhost:4444/wd/hub"
    kubectl -n default port-forward $POD_NAME 4444:4444

2. Within Kubernetes cluster, you can use following Service endpoint:
        http://selenium-grid-selenium-hub.default.svc:4444

I changed the url to:

driver = webdriver.Remote(
    # command_executor="http://selenium-grid-selenium-hub.default.svc.cluster.local:4444/wd/hub",
    command_executor="http://selenium-grid-selenium-hub.default.svc:4444",
    options=chrome_options
)

I also tried http://selenium-grid-selenium-hub.default.svc:4444/wd/hub but in both cases same error.

BTW nothing is logged by the hub deployment when trying to connect.

@VietND96
Copy link
Member

When you running the script on host, I don't think host could reach the DNS selenium-grid-selenium-hub.default.svc
Try to following steps to expose Hub to host port 4444

export POD_NAME=$(kubectl get pods -n default -l "app.kubernetes.io/name=selenium-grid-selenium-hub,app.kubernetes.io/instance=selenium-grid" -o jsonpath="{.items[0].metadata.name}")
kubectl -n default port-forward $POD_NAME 4444:4444

Then point your WebDriver tests to http://localhost:4444/wd/hub

@tamis-laan
Copy link
Author

@VietND96
I'm stupid but not that stupid ;-)

No I'm running the script as a kubernetes deployment in the same default namespace. I also tested it using a port forward as you described and I get the same error message.

@VietND96
Copy link
Member

I am not sure how the service type LoadBalancer works in Minikube. I would suggest another config that you can try

hub:
  serviceType: NodePort

And in script connect to http://localhost:31444/wd/hub

@tamasfe
Copy link

tamasfe commented Aug 29, 2024

I have run into this as well after bumping the chart version from 0.14.3 (yeah quite a leap).

Turns out the empty message shown by the python client is accompanied by a 401 status code because basic auth was changed to be enabled by default in the chart.

Setting the following chart value should resolve the issue:

basicAuth:
  enabled: false

I don't know about the reasoning behind enabling basic auth by default, I'd not expect it, especially since it is just admin:admin anyway. To make it actually useful one has to be aware that the option exists, and at that point it can be enabled if needed.

@VietND96
Copy link
Member

@tamasfe, thank you for your answer. It's correct, the basic auth is enabled by default in chart. In this case, the grid URL in binding would be

driver = webdriver.Remote(
    command_executor="http://admin:admin@localhost:4444",
    options=chrome_options
)

Copy link

github-actions bot commented Oct 9, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 2024
@VietND96
Copy link
Member

Exception message from the binding is improved via SeleniumHQ/selenium#14601

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants