当前位置: 代码迷 >> 综合 >> Appium1.18.x报错:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error
  详细解决方案

Appium1.18.x报错:selenium.common.exceptions.WebDriverException: Message: An unknown server-side error

热度:45   发布时间:2023-12-15 00:00:14.0

某一天,我的Appium程序找不到元素之后,就报了下面这样的错误:

Traceback (most recent call last):File "D:/PyChramProgram/spider/appium_douyin.py", line 42, in <module>viedo_author = driver.find_element_by_id("com.ss.android.ugc.aweme:id/title").textFile "D:\PyChramProgram\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 360, in find_element_by_idreturn self.find_element(by=By.ID, value=id_)File "D:\PyChramProgram\venv\lib\site-packages\appium\webdriver\webdriver.py", line 281, in find_element'value': value})['value']File "D:\PyChramProgram\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in executeself.error_handler.check_response(response)File "D:\PyChramProgram\venv\lib\site-packages\appium\webdriver\errorhandler.py", line 31, in check_responseraise wdeFile "D:\PyChramProgram\venv\lib\site-packages\appium\webdriver\errorhandler.py", line 26, in check_responsesuper().check_response(response)File "D:\PyChramProgram\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_responseraise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: An element could not be located on the page using the given search parameters.

这个错误其实只是在我页面上找不到我要定位的元素,估计是页面没加载完成就进行定位造成的!!!于是我添加了time.sleep()进行等待操作。
但是,在我添加后重新运行却报了另一个错误:

Traceback (most recent call last):File "D:/PyChramProgram/spider/appium_douyin.py", line 34, in <module>driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", cap)File "D:\PyChramProgram\venv\lib\site-packages\appium\webdriver\webdriver.py", line 155, in __init__proxyFile "D:\PyChramProgram\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__self.start_session(capabilities, browser_profile)File "D:\PyChramProgram\venv\lib\site-packages\appium\webdriver\webdriver.py", line 225, in start_sessionresponse = self.execute(RemoteCommand.NEW_SESSION, parameters)File "D:\PyChramProgram\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in executeself.error_handler.check_response(response)File "D:\PyChramProgram\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_responseraise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: An unknown server-side error occurred while processing the command. Original error: Could not acquire lock on C:\Users\maang\AppData\Local\Temp\uia2_device_port_guard. Original error: Error: EEXIST: file already exists, open 'C:\Users\maang\AppData\Local\Temp\uia2_device_port_guard

这我就傻了,翻译了大概就是找不到文件,我也不懂为啥文件就没了呀。。。
然后我卸载Appium,重新安装,如此反复了几次,还是不行。
最后把Appium1.18改成了1.17就可以了,我也不知道是为什么?知道原因的大佬们可以留言讲解一下哈~~~

  相关解决方案