qaf-python (NotADirectoryError: [WinError 267] The directory name is invalid)

155 views
Skip to first unread message

Stanley Ho

unread,
Jan 30, 2024, 1:43:14 AMJan 30
to qaf users
Hi qaf users,

Tried to execute qaf-python-helloworld example but encountered error.

Am running on a Windows machine. Another colleague of mine encountered the same issue.

However, a colleague ran on his Mac with no issues encountered.

Would appreciate if anyone in this group able to help with our issue.
Thanks.

Stanley

Following is the whole error message.
==========================================================

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

(venv) PS D:\Python-RobotFramework\qaf-python-helloworld> pytest
D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py:328: PluggyTeardownRaisedWarning: A plugin raised an exception during an old-style hookwrapper teardown.
Plugin: helpconfig, Hook: pytest_cmdline_parse                                                                                                                                                          
NotADirectoryError: [WinError 267] The directory name is invalid: 'D:\\Python-RobotFramework\\qaf-python-helloworld\\venv\\Lib\\site-packages\\qaf\\automation\\step_def\\__init__.py'                  
For more information see https://pluggy.readthedocs.io/en/stable/api_reference.html#pluggy.PluggyTeardownRaisedWarning                                                                                  
  config = pluginmanager.hook.pytest_cmdline_parse(                                                                                                                                                      
Traceback (most recent call last):                                                                                                  
  File "<frozen runpy>", line 198, in _run_module_as_main                                                                          
  File "<frozen runpy>", line 88, in _run_code                                                                                      
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Scripts\pytest.exe\__main__.py", line 7, in <module>                    
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py", line 189, in console_main
    code = main()                                                                                                                  
           ^^^^^^                                                                                                                  
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py", line 147, in main        
    config = _prepareconfig(args, plugins)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py", line 328, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\pluggy\_hooks.py", line 501, in __call__
    return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\pluggy\_manager.py", line 119, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\pluggy\_callers.py", line 155, in _multicall
    teardown[0].send(outcome)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\helpconfig.py", line 103, in pytest_cmdline_parse
    config: Config = outcome.get_result()
                     ^^^^^^^^^^^^^^^^^^^^
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\pluggy\_result.py", line 99, in get_result
    raise exc.with_traceback(exc.__traceback__)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\pluggy\_callers.py", line 102, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py", line 1077, in pytest_cmdline_parse
    self.parse(args)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py", line 1366, in parse
    self._preparse(args, addopts=addopts)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\config\__init__.py", line 1249, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\pluggy\_manager.py", line 414, in load_setuptools_entrypoints
    plugin = ep.load()
             ^^^^^^^^^
  File "D:\Program Files\Python\Python312\Lib\importlib\metadata\__init__.py", line 205, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Program Files\Python\Python312\Lib\importlib\__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\__init__.py", line 21, in <module>
    from qaf.listeners import pluginmagager, QAFWebDriverListener, QAFElementListener, StepListener
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\listeners.py", line 58, in <module>
    class StepListener:
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\listeners.py", line 59, in StepListener
    from qaf.automation.bdd2.qaf_teststep import StepTracker
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\automation\bdd2\__init__.py", line 20, in <module>
    from qaf.automation.bdd2.step_registry import *  # pylint: disable=wildcard-import
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\_pytest\assertion\rewrite.py", line 178, in exec_module
    exec(co, module.__dict__)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\automation\bdd2\step_registry.py", line 156, in <module>
    register_steps()
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\automation\bdd2\step_registry.py", line 145, in register_steps
    load_step_modules(QAF_STEPS)
  File "D:\Python-RobotFramework\qaf-python-helloworld\venv\Lib\site-packages\qaf\automation\bdd2\step_registry.py", line 113, in load_step_modules
    for name in sorted(os.listdir(path)):
                       ^^^^^^^^^^^^^^^^
NotADirectoryError: [WinError 267] The directory name is invalid: 'D:\\Python-RobotFramework\\qaf-python-helloworld\\venv\\Lib\\site-packages\\qaf\\automation\\step_def\\__init__.py'
Preparing For Shut Down...
(venv) PS D:\Python-RobotFramework\qaf-python-helloworld>

cjayswal

unread,
Feb 2, 2024, 1:35:57 AMFeb 2
to qaf users
Try force reinstall. It will unblock from above errors for windows. 

I was trying using firefox drive, Looks like python web driver client behavior is not same for different os so you may need to update test case accordingly in some cases. 
Another known issue for qaf-python on windows  is reporting. Still you can have standard pytest reporting.

cjayswal

unread,
Feb 3, 2024, 10:07:40 PMFeb 3
to qaf users
Now everything should work fine. Reporting issues for windows also get fixed along with odd behavior for is_displayed. 
Try force reinstall from qaf-python master and it should work in windows system as will.

Stanley Ho

unread,
Feb 4, 2024, 10:16:04 PMFeb 4
to qaf users
Thank you for resolving my issue, Chirag!

Stanley Ho

unread,
Mar 11, 2024, 3:33:02 AMMar 11
to qaf users
Hi cjayswal,

Seems like the qaf-python source has a typo error.
The `webdriver.<browsername>.driver` property is not consistent in the source. The string has double `..` instead of `.`
For your clarifications.
Thanks

s9a6Julccs.png

Uz0wJA7rrZ.png

Reply all
Reply to author
Forward
0 new messages