0

I'm facing an import error when trying to run a behave .feature test from windows prompt:

C:\MyProject\Features> behave
    Exception ImportError: No module named Pages.SamplePage
    Traceback (most recent call last):
      File "C:/Python27/Lib/site-packages/behave/__main__.py", line 162, in <module>
        sys.exit(main())
      File "C:/Python27/Lib/site-packages/behave/__main__.py", line 109, in main
        failed = runner.run()
      File "C:\Python27\lib\site-packages\behave\runner.py", line 672, in run
        return self.run_with_paths()
      File "C:\Python27\lib\site-packages\behave\runner.py", line 678, in run_with_paths
        self.load_step_definitions()
      File "C:\Python27\lib\site-packages\behave\runner.py", line 658, in load_step_definitions
        exec_file(os.path.join(path, name), step_module_globals)
      File "C:\Python27\lib\site-packages\behave\runner.py", line 304, in exec_file
        exec(code, globals, locals)
      File "steps\SampleSteps.py", line 5, in <module>
        from Pages.SamplePage import SamplePage
    ImportError: No module named Pages.SamplePage

The same test works perfectly from PyCharm/Run/Debug. But I would like to run my tests from prompt in order to execute my suite from Jenkins in the future...

I already tried to include my project path to the Windows path, but it didn't work.

This is my project structure:

- MyProject
  - Features
    - __init__.py
    - Environment.py
    - Sample
      - __init__.py
      - sample.feature
    - Steps
      - __init__.py
      - SampleSteps.py
  - Pages
    - __init__.py
    - SamplePage.py

0 Answers0