appium运行时,报500,代码提示找不到Java环境(代码和报错文件在内容中)

from appium import webdriver

desired_caps = {}
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '6.0'
desired_caps['deviceName'] = '127.0.0.1:7555'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'
driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
driver.quit()

报错

C:\Users\ttt\python_test202110\venv\Scripts\python.exe C:/Users/ttt/python_test202110/test_app/demo1.py
Traceback (most recent call last):
  File "C:\Users\ttt\python_test202110\test_app\demo1.py", line 17, in <module>
    driver = webdriver.Remote('http://localhost:4723/wd/hub',desired_caps)
  File "C:\Users\ttt\python_test202110\venv\lib\site-packages\appium\webdriver\webdriver.py", line 273, in __init__
    super().__init__(
  File "C:\Users\ttt\python_test202110\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
    self.start_session(capabilities, browser_profile)
  File "C:\Users\ttt\python_test202110\venv\lib\site-packages\appium\webdriver\webdriver.py", line 364, in start_session
    response = self.execute(RemoteCommand.NEW_SESSION, parameters)
  File "C:\Users\ttt\python_test202110\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
    self.error_handler.check_response(response)
  File "C:\Users\ttt\python_test202110\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate. Original error Command 'C:\Program Files\Java\bin\java.exe' not found. Is it installed?
Stacktrace:
UnknownError: An unknown server-side error occurred while processing the command. Original error: Could not sign with default certificate. Original error Command 'C:\Program Files\Java\bin\java.exe' not found. Is it installed?
    at getResponseForW3CError (C:\Users\ttt\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\errors.js:804:9)
    at asyncHandler (C:\Users\ttt\AppData\Local\Programs\Appium\resources\app\node_modules\appium\node_modules\appium-base-driver\lib\protocol\protocol.js:381:37)

Process finished with exit code 1

appium上的报错

看下你的这个文件在不在,估计是你的PATH变量设置的有问题。看下你的系统变量里的配置吧。把正确的java路径放到PATH变量里。

我重新检查了一下Java环境变量,有多个Java环境,然后我清理重新配置Java环境变量,现在OK。多谢思寒大佬指点 :pray:

关闭