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 wont start with none message shown. #14219

Open
woshichuanqilz opened this issue Jul 2, 2024 · 35 comments
Open

[🐛 Bug]: selenium wont start with none message shown. #14219

woshichuanqilz opened this issue Jul 2, 2024 · 35 comments

Comments

@woshichuanqilz
Copy link

woshichuanqilz commented Jul 2, 2024

What happened?

Basic code of selenium failed to start.
I tried code

Code 1

import logging
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
CHROMEDRIVER_PATH = '/home/lizhe/Applications/chromedriver-linux64/chromedriver'
options = webdriver.ChromeOptions()
options.binary_location = '/home/lizhe/Applications/chrome-linux64/chrome'
service = ChromeService(executable_path=CHROMEDRIVER_PATH)
driver = webdriver.Chrome(service=service, options=options)

url = "https://www.google.com"
driver.get(url)
input("please wait...")

I get error message:


Traceback (most recent call last):
  File "/home/lizhe/test2.py", line 22, in <module>
    driver = webdriver.Chrome(service=s)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

Code 2

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
CHROMEDRIVER_PATH = '/home/lizhe/Applications/chromedriver-linux64/chromedriver'
options = webdriver.ChromeOptions()
options.binary_location = '/home/lizhe/Applications/chrome-linux64/chrome'
service = ChromeService(executable_path=CHROMEDRIVER_PATH)
driver = webdriver.Chrome(service=service, options=options)

url = "https://www.google.com"
driver.get(url)
input("please wait...")

get error message

Traceback (most recent call last):
  File "/home/lizhe/test2.py", line 7, in <module>
    driver = webdriver.Chrome(service=service, options=options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

How can we reproduce the issue?

Just install the selenium and run the code I mentioned above with my os env.

Relevant log output

-- log for code 1
Skipping Selenium Manager; path to chrome driver specified in Service class: /home/lizhe/Applications/chromedriver-linux64/chromedriver
Started executable: `/home/lizhe/Applications/chromedriver-linux64/chromedriver` in a child process with pid: 1438254 using 0 to output -3

-- log for code 2
Skipping Selenium Manager; path to chrome driver specified in Service class: /home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64/chromedriver
Started executable: `/home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64/chromedriver` in a child process with pid: 1448626 using 0 to output -3

Operating System

Manjaro Linux Wynsdey 24.0.2 x86_64

Selenium version

4.22.0

What are the browser(s) and version(s) where you see this issue?

Google Chrome 126.0.6478.126

What are the browser driver(s) and version(s) where you see this issue?

ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591})

Are you using Selenium Grid?

no

Other info

hosts file contains 127.0.0.1 localhost

OS: Manjaro Linux Wynsdey 24.0.2 x86_64
Kernel: Linux 6.6.32-1-MANJARO
Uptime: 2 days, 20 hours, 52 mins
Packages: 1715 (pacman)[stable]
Shell: fish 3.7.1
Display (U32R59x): 3840x2160 @ 60Hz *
Display (U32R59x): 3840x2160 @ 60Hz
DE: KDE Plasma 6.0.5
WM: i3 (X11)
Theme: Breeze (BreathLight) [QT], Breeze [GTK2/3]
Icons: breeze [QT], breeze [GTK2/3/4]
Font: Noto Sans (10pt) [QT], Noto Sans (10pt) [GTK2/3/4]
Cursor: breeze (24px)
Terminal: zellij 0.40.1
CPU: 12th Gen Intel(R) Core(TM) i7-12700K (20) @ 5.00 GHz
GPU: NVIDIA GeForce GTX 1050 Ti [Discrete]
Memory: 13.76 GiB / 31.09 GiB (44%)
Swap: 0 B / 8.80 GiB (0%)
Disk (/): 91.91 GiB / 224.71 GiB (41%) - ext4
Local IP (enp6s0): 192.168.3.96/24 *
Locale: en_US.UTF-8
Copy link

github-actions bot commented Jul 2, 2024

@woshichuanqilz, 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!

@diemol
Copy link
Member

diemol commented Jul 2, 2024

What happens when you execute on the terminal /home/lizhe/Applications/chromedriver-linux64/chromedriver and /home/lizhe/Applications/chrome-linux64/chrome?

Please share the terminal output.

@woshichuanqilz
Copy link
Author

What happens when you execute on the terminal /home/lizhe/Applications/chromedriver-linux64/chromedriver and /home/lizhe/Applications/chrome-linux64/chrome?

Please share the terminal output.

> /home/lizhe/Applications/chromedriver-linux64/chromedriver                                                                                
Starting ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

--- 

> /home/lizhe/Applications/chrome-linux64/chrome                                                                                            
Created TensorFlow Lite XNNPACK delegate for CPU.
Attempting to use a delegate that only supports static-sized tensors w
ith a graph that has dynamic-sized tensors (tensor#141 is a dynamic-si
zed tensor).

@diemol
Copy link
Member

diemol commented Jul 2, 2024

That output looks strange for Chrome, is that the correct binary?

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

That output looks strange for Chrome, is that the correct binary?

I use

That output looks strange for Chrome, is that the correct binary?

The chrome I used above is from here: https://googlechromelabs.github.io/chrome-for-testing. Not my daily use chrome

Then I change the code to this (comment the options.binary_location = '/home/lizhe/Applications/chrome-linux64/chrome) which may use the daily used chrome instead I think

import logging
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
CHROMEDRIVER_PATH = '/home/lizhe/Applications/chromedriver-linux64/chromedriver'
options = webdriver.ChromeOptions()
# options.binary_location = '/home/lizhe/Applications/chrome-linux64/chrome'
service = ChromeService(executable_path=CHROMEDRIVER_PATH)
driver = webdriver.Chrome(service=service, options=options)

url = "https://www.google.com"
driver.get(url)
input("please wait...")

Then I get error msg :

Traceback (most recent call last):
  File "/home/lizhe/test2.py", line 23, in <module>
    driver = webdriver.Chrome(service=service, options=options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 292, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

My daily used chrome version

google-chrome-stable --version                                   ─╯
Google Chrome 126.0.6478.126

Msg output when run daily used chrome:

Opening in existing browser session.

@diemol
Copy link
Member

diemol commented Jul 2, 2024

Why don't you let Selenium Manager manage it?

Leave it like:

driver = webdriver.Chrome()

@woshichuanqilz
Copy link
Author

Why don't you let Selenium Manager manage it?

Leave it like:

driver = webdriver.Chrome()

At first I just try the code like you write.
But I get error msg like this, no useful msg shows out, cause the Message string is empty. I do some google work said that it may related to the chromedriver not found. So I change the code.

Still error.

Here is the code I tried at first.

import logging
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
driver = webdriver.Chrome()

url = "https://www.google.com"
driver.get(url)
input("please wait...")
Traceback (most recent call last):
  File "/home/lizhe/tes3.py", line 20, in <module>
    driver = webdriver.Chrome()
             ^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdri
ver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdri
ver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdri
ver/remote/webdriver.py", line 208, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdri
ver/remote/webdriver.py", line 292, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdri
ver/remote/webdriver.py", line 347, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/.local/lib/python3.12/site-packages/selenium/webdri
ver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

@diemol
Copy link
Member

diemol commented Jul 2, 2024

I don't see the log contents, just the stacktrace.

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

I don't see the log contents, just the stacktrace.

What is the stacktrace how to get it ?

When I run chrome from command line output : Opening in existing browser session.

@diemol
Copy link
Member

diemol commented Jul 2, 2024

What are the contents of ori.log?

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

What are the contents of ori.log?
code

import logging
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
driver = webdriver.Chrome()

url = "https://www.google.com"
driver.get(url)
input("please wait...")

ori.log

Selenium Manager binary found at: /home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: /home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --debug --language-binding python --output json
Found chromedriver 126.0.6478.126 in PATH: /home/lizhe/Applications/chromedriver-linux64/chromedriver
Found chrome in PATH: /home/lizhe/Applications/chrome-linux64/chrome
Running command: /home/lizhe/Applications/chrome-linux64/chrome --version
Output: "Google Chrome for Testing 126.0.6478.126 "
Detected browser: chrome 126.0.6478.126
Required driver: chromedriver 126.0.6478.126
Driver path: /home/lizhe/Applications/chromedriver-linux64/chromedriver
Browser path: /home/lizhe/Applications/chrome-linux64/chrome
Started executable: `/home/lizhe/Applications/chromedriver-linux64/chromedriver` in a child process with pid: 1951526 using 0 to output -3

the log seems shows that the chrome not found

I change the code

import logging
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome-stable'
driver = webdriver.Chrome(options)

url = "https://www.google.com"
driver.get(url)
input("please wait...")

ori.log

Selenium Manager binary found at: /home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: /home/lizhe/.local/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --browser-path /usr/bin/google-chrome-stable --debug --language-binding python --output json
Found chromedriver 126.0.6478.126 in PATH: /home/lizhe/Applications/chromedriver-linux64/chromedriver
Running command: /usr/bin/google-chrome-stable --version
Output: "Google Chrome 126.0.6478.126 "
Detected browser: chrome 126.0.6478.126
Required driver: chromedriver 126.0.6478.126
Driver path: /home/lizhe/Applications/chromedriver-linux64/chromedriver
Browser path: /usr/bin/google-chrome-stable
Started executable: `/home/lizhe/Applications/chromedriver-linux64/chromedriver` in a child process with pid: 1957474 using 0 to output -3

@diemol
Copy link
Member

diemol commented Jul 2, 2024

Somehow the ChromeDriver you have in path is exiting with code -3.

Can you delete that binary and let Selenium Manager download it?

@woshichuanqilz
Copy link
Author

Somehow the ChromeDriver you have in path is exiting with code -3.

Can you delete that binary and let Selenium Manager download it?

Can you give me a link about how to use selenium to download the driver?

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

Somehow the ChromeDriver you have in path is exiting with code -3.

Can you delete that binary and let Selenium Manager download it?

I change the code to this.

import logging
from webdriver_manager.chrome import ChromeDriver
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)



test_logging('ori.log')
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome-stable'
driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install()))

url = "https://www.google.com"
driver.get(url)
input("please wait...")

output of command line said cant find chrome but I set it in the option, it is google-chrome-stable

╰─❯ python tes3.py                            
/bin/sh: line 1: google-chrome: command not found
/bin/sh: line 1: google-chrome: command not found
Traceback (most recent call last):
  File "/home/lizhe/tes3.py", line 24, in <module
    driver = webdriver.Chrome(options=options, se
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

ori.log

Skipping Selenium Manager; path to chrome driver specified in Service class: /home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64/chromedriver
Started executable: `/home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64/chromedriver` in a child process with pid: 1970029 using 0 to output -3

@woshichuanqilz
Copy link
Author

I create a symbolic link to google-chrome-stable named google-chrome.

Rerun the code

output

Traceback (most recent call last):
  File "/home/lizhe/tes3.py", line 30, in <module>
    driver = webdriver.Chrome(options=options, service=ChromeService(ChromeDriverManager().install()))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

ori.log

Skipping Selenium Manager; path to chrome driver specified in Service class: /home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64/chromedriver
Started executable: `/home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64/chromedriver` in a child process with pid: 1974167 using 0 to output -3

@diemol
Copy link
Member

diemol commented Jul 2, 2024

You are going in circles, this is the same code you used to create the issue.

What I requested is for you to delete the ChromeDriver that you have on path and let Selenium Manager handle it.

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

You are going in circles, this is the same code you used to create the issue.

What I requested is for you to delete the ChromeDriver that you have on path and let Selenium Manager handle it.

I already delete the chromedriver. As you can see in the ori.log. The chromedriver is in the .wdm folder.
which chromedriver wont locate any chromedriver

And the .wdm I also delete and re-download again.

@krmahadevan
Copy link
Contributor

@woshichuanqilz - I think you are mixing selenium and the webdrivermanager packages.

Can you please try the below sample and post back what you see ?

import logging

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome-stable'
driver = webdriver.Chrome(options=options, service=ChromeService())

url = "https://www.google.com"
driver.get(url)
print("Page title: ", driver.title)
driver.quit()

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

@woshichuanqilz - I think you are mixing selenium and the webdrivermanager packages.

Can you please try the below sample and post back what you see ?

import logging

from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService


def test_logging(log_path):
    logger = logging.getLogger('selenium')

    logger.setLevel(logging.DEBUG)

    handler = logging.FileHandler(log_path)
    logger.addHandler(handler)

    logging.getLogger('selenium.webdriver.remote').setLevel(logging.WARN)
    logging.getLogger('selenium.webdriver.common').setLevel(logging.DEBUG)


test_logging('ori.log')
options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/google-chrome-stable'
driver = webdriver.Chrome(options=options, service=ChromeService())

url = "https://www.google.com"
driver.get(url)
print("Page title: ", driver.title)
driver.quit()

output

Traceback (most recent call last):
  File "/home/lizhe/tes3.py", line 23, in <module>
    driver = webdriver.Chrome(options=options, service=ChromeService())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

ori.log

Selenium Manager binary found at: /home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: /home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --browser-path /usr/bin/google-chrome-stable --debug --language-binding python --output json
chromedriver not found in PATH
Running command: /usr/bin/google-chrome-stable --version
Output: "Google Chrome 126.0.6478.126 "
Detected browser: chrome 126.0.6478.126
Required driver: chromedriver 126.0.6478.126
chromedriver 126.0.6478.126 already in the cache
Driver path: /home/lizhe/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver
Browser path: /usr/bin/google-chrome-stable
Started executable: `/home/lizhe/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver` in a child process with pid: 1989137 using 0 to output -3

@krmahadevan
Copy link
Contributor

@woshichuanqilz - For the last experiment, can you please comment out

options.binary_location = '/usr/bin/google-chrome-stable'

and re-run the sample? Basically we are trying to figure out as to what happens when selenium internally uses selenium manager to download the browser as well and then work with it.

In my case, when I had ran that sample on my mac, I got the below message in the logs (which re-iterates what I already knew i.e., the browser was not present in that path)

Running command: /usr/bin/google-chrome-stable --version
Output: ""
chrome not found in the system
Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json
Required browser: chrome 126.0.6478.126
Downloading chrome 126.0.6478.126 from https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.126/mac-x64/chrome-mac-x64.zip
chrome 126.0.6478.126 is available at /Users/kmahadevan/.cache/selenium/chrome/mac-x64/126.0.6478.126/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing

@woshichuanqilz
Copy link
Author

@woshichuanqilz - For the last experiment, can you please comment out

options.binary_location = '/usr/bin/google-chrome-stable'

and re-run the sample? Basically we are trying to figure out as to what happens when selenium internally uses selenium manager to download the browser as well and then work with it.

In my case, when I had ran that sample on my mac, I got the below message in the logs (which re-iterates what I already knew i.e., the browser was not present in that path)

Running command: /usr/bin/google-chrome-stable --version
Output: ""
chrome not found in the system
Discovering versions from https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json
Required browser: chrome 126.0.6478.126
Downloading chrome 126.0.6478.126 from https://storage.googleapis.com/chrome-for-testing-public/126.0.6478.126/mac-x64/chrome-mac-x64.zip
chrome 126.0.6478.126 is available at /Users/kmahadevan/.cache/selenium/chrome/mac-x64/126.0.6478.126/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing

output

Traceback (most recent call last):
  File "/home/lizhe/tes3.py", line 22, in <module>
    driver = webdriver.Chrome(options=options, service=ChromeService())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in __init__
    super().__init__(
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in __init__
    super().__init__(command_executor=executor, options=options)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in __init__
    self.start_session(capabilities)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
    response = self.execute(Command.NEW_SESSION, caps)["value"]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
    self.error_handler.check_response(response)
  File "/home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/remote/errorhandler.py", line 193, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message:

ori.log

Selenium Manager binary found at: /home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager
Executing process: /home/lizhe/pyvenvL/.venv/lib/python3.12/site-packages/selenium/webdriver/common/linux/selenium-manager --browser chrome --debug --language-binding python --output json
chromedriver not found in PATH
chrome not found in PATH
chrome not found in the system
Required browser: chrome 126.0.6478.126
chrome 126.0.6478.126 already exists
chrome 126.0.6478.126 is available at /home/lizhe/.cache/selenium/chrome/linux64/126.0.6478.126/chrome
Required driver: chromedriver 126.0.6478.126
chromedriver 126.0.6478.126 already in the cache
Driver path: /home/lizhe/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver
Browser path: /home/lizhe/.cache/selenium/chrome/linux64/126.0.6478.126/chrome
Started executable: `/home/lizhe/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver` in a child process with pid: 1997294 using 0 to output -3

@krmahadevan
Copy link
Contributor

Ok. My guess is that there is some issue when it comes to executing the chromedriver binary in your machine.

Have you tried manually running to see if it works fine ?

Here's what I see.

➜  126.0.6478.126 pwd
/Users/kmahadevan/.cache/selenium/chromedriver/mac-x64/126.0.6478.126
➜  126.0.6478.126 ls -ltr
total 36944
-rwxr-xr-x@ 1 kmahadevan  staff  18911688 Jun 28 21:45 chromedriver
➜  126.0.6478.126 ./chromedriver -v
ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591})
➜  126.0.6478.126

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 2, 2024

Ok. My guess is that there is some issue when it comes to executing the chromedriver binary in your machine.还行。我的猜测是在您的机器中执行 chromedriver 二进制文件时存在一些问题。

Have you tried manually running to see if it works fine ?您是否尝试过手动运行以查看它是否正常工作?

Here's what I see.这是我所看到的。

➜  126.0.6478.126 pwd
/Users/kmahadevan/.cache/selenium/chromedriver/mac-x64/126.0.6478.126
➜  126.0.6478.126 ls -ltr
total 36944
-rwxr-xr-x@ 1 kmahadevan  staff  18911688 Jun 28 21:45 chromedriver
➜  126.0.6478.126 ./chromedriver -v
ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591})
➜  126.0.6478.126
╰─❯ pwd                                                                                                                                       ─╯
/home/lizhe/.wdm/drivers/chromedriver/linux64/126.0.6478.126/chromedriver-linux64

╰─❯ ./chromedriver -v                                                                                                                         ─╯
ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591})

>  ./chromedriver                                                                                                                            ─╯
Starting ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

You just need this?

@krmahadevan
Copy link
Contributor

@woshichuanqilz - yeah that output rules out any issues with chromedriver.

I noticed in this comment #14219 (comment) that you mentioned you are using CFT version of google chrome. I don't know if that can be related to the problem or not.

So to rule out the role of the CFT version of Google chrome, can we try this as well?

  1. Start the chromedriver as you did in your earlier comment.
  2. Run a curl command as below and check if you are seeing chrome browser open up and also see a JSON response as below ?
#!/bin/sh
curl --location 'localhost:9515/session' \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{
  "capabilities": {
    "firstMatch": [
      {
        "browserName": "chrome"
      }
    ]
  }
}'

JSON response on the terminal

{"value":{"capabilities":{"acceptInsecureCerts":false,"browserName":"chrome","browserVersion":"126.0.6478.127","chrome":{"chromedriverVersion":"126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591})","userDataDir":"/var/folders/1f/rc_t2_qj41x3_9n8bhn5grr00000gn/T/.org.chromium.Chromium.8Zi5VJ"},"fedcm:accounts":true,"goog:chromeOptions":{"debuggerAddress":"localhost:63445"},"networkConnectionEnabled":false,"pageLoadStrategy":"normal","platformName":"mac","proxy":{},"setWindowRect":true,"strictFileInteractability":false,"timeouts":{"implicit":0,"pageLoad":300000,"script":30000},"unhandledPromptBehavior":"dismiss and notify","webauthn:extension:credBlob":true,"webauthn:extension:largeBlob":true,"webauthn:extension:minPinLength":true,"webauthn:extension:prf":true,"webauthn:virtualAuthenticators":true},"sessionId":"87213362fb6d1bac0c7a26c33502a3e1"}

@krmahadevan
Copy link
Contributor

Also.. I think the .wdm directory is from Webdriver manager. Selenium stores all its driver and browser binaries under .cache directory which is different. Please check that once.

@woshichuanqilz
Copy link
Author

  • 是的,输出排除了 ChromeRiver 的任何问题。

I noticed in this comment #14219 (comment) that you mentioned you are using CFT version of google chrome. I don't know if that can be related to the problem or not.

I already delete CFT chrome since this post above. Just use the normal chrome. Same issue.

Start the chromedriver as you did in your earlier comment.
Run a curl command as below and check if you are seeing chrome browser open up and also see a JSON response as below ?

You mean start the chromedriver first, then run the curl command? Nothing shows in the terminal.
The chrome name on my pc is google-chrome-stable. I change browserName to google-chrome-stable not msg shown either.

I use browser to access "http://localhost:9515/"
And get this:

{"value":{"error":"unknown command","message":"unknown command: unknown command: ","stacktrace":"#0 0x555f937f8c7a \u003Cunknown>\n#1 0x555f934dbe2c \u003Cunknown>\n#2 0x555f935453f9 \u003Cunknown>\n#3 0x555f93544f8a \u003Cunknown>\n#4 0x555f934a6a88 \u003Cunknown>\n#5 0x555f937bf24b \u003Cunknown>\n#6 0x555f937c32f1 \u003Cunknown>\n#7 0x555f937aaafe \u003Cunknown>\n#8 0x555f937c3e52 \u003Cunknown>\n#9 0x555f9378f79f \u003Cunknown>\n#10 0x555f934a5066 \u003Cunknown>\n#11 0x7fb72d251c88 \u003Cunknown>\n#12 0x7fb72d251d4c __libc_start_main\n#13 0x555f934700ea _start\n"}}

Also.. I think the .wdm directory is from Webdriver manager. Selenium stores all its driver and browser binaries under .cache directory which is different. Please check that once.

.wdm

╰─❯ pwd                                                              ─╯
/home/lizhe/.wdm

╭─ ~/.wdm                                                          ─╮
╰─❯ tree                                                             ─╯
.
├── drivers
│   └── chromedriver
│       └── linux64
│           └── 126.0.6478.126
│               ├── chromedriver-linux64
│               │   ├── chromedriver
│               │   └── LICENSE.chromedriver
│               └── chromedriver-linux64.zip
└── drivers.json

.cache Contains chrome and chromedriver

  • /home/lizhe/.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver
  • /home/lizhe/.cache/selenium/chrome/linux64/126.0.6478.126/chrome

@krmahadevan
Copy link
Contributor

You mean start the chromedriver first, then run the curl command? Nothing shows in the terminal.

Yes. That's what I meant. What happens on the terminal when you do that? Does it exit immediately or do you see the prompt stall? Do you see a browser open up?

The chrome name on my pc is google-chrome-stable. I change browserName to google-chrome-stable not msg shown either.

I dont think that the name of the browser binary matters. You should use chrome.

@woshichuanqilz
Copy link
Author

Yes. That's what I meant. What happens on the terminal when you do that? Does it exit immediately or do you see the prompt stall? Do you see a browser open up?

Nothing happens.
No output in ther terminal . And browser don't start

@krmahadevan
Copy link
Contributor

@woshichuanqilz - What if you start chromedriver with debug logs enabled and then trigger the curl command ?

For me I see something like below

➜  126.0.6478.126 ./chromedriver --log-level=DEBUG
Starting ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
[1720008443.822][INFO]: [0391bbb4813c119ff3973f4c446924ff] COMMAND InitSession {
   "capabilities": {
      "firstMatch": [ {
         "browserName": "chrome"
      } ]
   }
}
[1720008443.822][INFO]: Browser search. Trying... /Users/kmahadevan/.cache/selenium/chromedriver/mac-x64/126.0.6478.126/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing
[1720008443.822][INFO]: Browser search. Trying... /Users/kmahadevan/.cache/selenium/chromedriver/mac-x64/126.0.6478.126/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing
[1720008443.822][INFO]: Browser search. Trying... /Users/kmahadevan/.cache/selenium/chromedriver/mac-x64/126.0.6478.126/Google Chrome.app/Contents/MacOS/Google Chrome
[1720008443.822][INFO]: Browser search. Trying... /Users/kmahadevan/.cache/selenium/chromedriver/mac-x64/126.0.6478.126/Chromium.app/Contents/MacOS/Chromium

Its a verbose log and so I have trimmed the rest of the output.

@woshichuanqilz
Copy link
Author

--log-level=DEBUG
╰─❯ .cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver --log-level=DEBUG                                                        ─╯
Starting ChromeDriver 126.0.6478.126 (d36ace6122e0a59570e258d82441395206d60e1c-refs/branch-heads/6478@{#1591}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

Same with no debug flag

@krmahadevan
Copy link
Contributor

@woshichuanqilz - If you are not able to run chromedriver and have it spin off a chrome browser, I think it could be an issue with chromedriver itself for your particular platform.

@diemol WDYT ?

@diemol
Copy link
Member

diemol commented Jul 3, 2024

I don't think you followed the steps we are asking...

Step one, in an empty terminal, where the ChromeDriver binary is placed do:

.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver --log-level=DEBUG

Step do, in a new terminal, execute:

#!/bin/sh
curl --location 'localhost:9515/session' \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{
  "capabilities": {
    "firstMatch": [
      {
        "browserName": "chrome"
      }
    ]
  }
}'

Please share the output from both terminals and tell us if the browser opens or not.

@woshichuanqilz
Copy link
Author

woshichuanqilz commented Jul 3, 2024

I don't think you followed the steps we are asking...

Step one, in an empty terminal, where the ChromeDriver binary is placed do:

.cache/selenium/chromedriver/linux64/126.0.6478.126/chromedriver --log-level=DEBUG

Step do, in a new terminal, execute:

#!/bin/sh
curl --location 'localhost:9515/session' \
--header 'Content-Type: application/json; charset=utf-8' \
--data '{
  "capabilities": {
    "firstMatch": [
      {
        "browserName": "chrome"
      }
    ]
  }
}'

Please share the output from both terminals and tell us if the browser opens or not.

browser not open . no output

image

@diemol
Copy link
Member

diemol commented Jul 4, 2024

I am not sure what is wrong with your machine. Or is that terminal connected to another machine, and are you executing commands on a different VM?

What happens if you try it on a different machine?

If this was an actual problem, we would have many open issues.

@krmahadevan
Copy link
Contributor

For the sake of completeness I setup a VM with the same OS flavor (Manjaro Linux)

Operating System: Manjaro Linux 
KDE Plasma Version: 6.0.5
KDE Frameworks Version: 6.3.0
Qt Version: 6.7.1
Kernel Version: 6.9.3-3-MANJARO (64-bit)
Graphics Platform: X11
Processors: 2 × Intel® Core™ i7-9750H CPU @ 2.60GHz
Memory: 3.8 GiB of RAM
Graphics Processor: llvmpipe
Manufacturer: VMware, Inc.
Product Name: VMware Virtual Platform
System Version: None

and tried running the same test as well as the curl command.

In both the cases, it worked fine.

Note: I had to install chrome using the command pamac build google-chrome ( see this blog for details ) before running the curl command because chromedriver just works with what exists on the system and doesn't necessarily download the browser. I believe all of this magic is done by Selenium Manager, which will come into picture only when you run a test code (python sample in our case)

So I think there's something wrong in the machine in question.

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

No branches or pull requests

3 participants