alibaba / alibaba/tidevice

sleep 60秒后,出现A session is either terminated or not started

Open
#129 1 comment 0 reactions 0 assignees View on GitHub
invalid
Dominant language
Python
Stars
2.6k
Forks
469
PR merge metrics
No merged PRs in 30d

Description

> python+appium iOS APP自动化

代码中有个语句`time.sleep(60)`,60秒后,代码往后运行就出现错误
```
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\_pytest\main.py", line 269, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\_pytest\main.py", line 323, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\manager.py", line 84, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\_pytest\main.py", line 348, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\manager.py", line 84, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 208, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 80, in get_result
INTERNALERROR> raise ex[1].with_traceback(ex[2])
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 187, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\_pytest\runner.py", line 109, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\_pytest\runner.py", line 126, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\_pytest\runner.py", line 217, in call_and_report
INTERNALERROR> report: TestReport = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\hooks.py", line 286, in __call__
INTERNALERROR> return self._hookexec(self, self.get_hookimpls(), kwargs)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\manager.py", line 93, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\manager.py", line 84, in
INTERNALERROR> self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\pluggy\callers.py", line 203, in _multicall
INTERNALERROR> gen.send(outcome)
INTERNALERROR> File "D:\code\eufy_security_smoke\src\case\conftest.py", line 671, in pytest_runtest_makereport
INTERNALERROR> screenshot_html = save_screenshot(path, html_path, name)
INTERNALERROR> File "D:\code\eufy_security_smoke\src\case\conftest.py", line 780, in save_screenshot
INTERNALERROR> get_screenshot(driver, path_name) # 兼容h5截图
INTERNALERROR> File "D:\code\eufy_security_smoke\src\case\conftest.py", line 705, in get_screenshot
INTERNALERROR> current_c = driver.current_context
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\appium\webdriver\extensions\context.py", line 52, in current_context
INTERNALERROR> return self.execute(Command.GET_CURRENT_CONTEXT)['value']
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
INTERNALERROR> self.error_handler.check_response(response)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\appium\webdriver\errorhandler.py", line 31, in check_response
INTERNALERROR> raise wde
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\appium\webdriver\errorhandler.py", line 26, in check_response
INTERNALERROR> super().check_response(response)
INTERNALERROR> File "D:\code\eufy_security_smoke\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
INTERNALERROR> raise exception_class(message, screen, stacktrace)
INTERNALERROR> selenium.common.exceptions.WebDriverException: Message: A session is either terminated or not started
```

我又在macOS中跑了一下,`time.sleep(60)`并没有影响代码的往后运行。
所以不知道是`tidevice`的问题,还是我环境的问题?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with src/case/conftest.py, especially pytest_runtest_makereport, save_screenshot, and get_screenshot, then reproduce the failure around time.sleep(60) in the reported iOS Appium test. Compare the Windows and macOS runs and inspect the reported current_context failure. Done means determining whether tidevice or the environment causes the terminated session and documenting the confirmed conditions.

Written by the indexing model from the issue text.

Assessment

Tech stack
ios, python
Domain
mobile-dev, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.