spyoungtech / behave-webdriver

Selenium webdriver step library for use with the behave BDD testing framework
MIT License
62 stars 21 forks source link

can't run minimal-project #68

Closed mikelietz closed 5 years ago

mikelietz commented 5 years ago

I'm attempting to use this in Python 2.7 on a Mac. I installed behave and behave-webdriver via pip.

examples $ cd minimal-project/
minimal-project $ behave
Exception ImportError: cannot import name BehaveDriver
Traceback (most recent call last):
  File "/usr/local/bin/behave", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/site-packages/behave/__main__.py", line 183, in main
    return run_behave(config)
  File "/usr/local/lib/python2.7/site-packages/behave/__main__.py", line 127, in run_behave
    failed = runner.run()
  File "/usr/local/lib/python2.7/site-packages/behave/runner.py", line 804, in run
    return self.run_with_paths()
  File "/usr/local/lib/python2.7/site-packages/behave/runner.py", line 808, in run_with_paths
    self.load_hooks()
  File "/usr/local/lib/python2.7/site-packages/behave/runner.py", line 784, in load_hooks
    exec_file(hooks_path, self.hooks)
  File "/usr/local/lib/python2.7/site-packages/behave/runner_util.py", line 386, in exec_file
    exec(code, globals_, locals_)
  File "features/environment.py", line 1, in <module>
    from behave_webdriver import BehaveDriver
ImportError: cannot import name BehaveDriver
mikelietz commented 5 years ago

If I attempt to run selenium-requests instead, the ImportError I get is for 'parse'. Pip tells me that's installed.

spyoungtech commented 5 years ago

Thanks for reporting this issue @mikelietz

It looks like there are two problems here.

(1) The minimal example will need to be updated for the current release, as BehaveDriver has been removed and replaced with regular selenium class names.

(2) The selenium-requests example, as written, only works on Python3 right now. Though, making this example Py2 compatible shouldn't be too much work.

I'll address these problems shortly.

spyoungtech commented 5 years ago

Hey @mikelietz

I just updated the examples in the master branch. In the process, I also discovered another bug ( #69 ) along the way, which I just merged a patch for and released in v0.2.2

You should be all set with these latest changes. Let me know if that works for you.

mikelietz commented 5 years ago

Thanks for the quick update! I grabbed the latest and tried to run it - it does execute now but now there are TypeErrors:

minimal-project $ behave
Feature: Sample Snippets test # features/myFeature.feature:2
  As a developer
  I should be able to use given text snippets
  Scenario: open URL                                                          # features/myFeature.feature:6
    Given the page url is not "http://webdriverjs.christian-bromann.com/"     # ../../../../../../usr/local/lib/python2.7/site-packages/behave_webdriver/steps/expectations.py:149 0.002s
      Traceback (most recent call last):
        File "/usr/local/lib/python2.7/site-packages/behave/model.py", line 1329, in run
          match.run(runner.context)
        File "/usr/local/lib/python2.7/site-packages/behave_webdriver/transformers.py", line 111, in run
          if transformer_class and (isinstance(transformer_class, partial) and issubclass(transformer_class.func, TransformerBase)) or issubclass(transformer_class, TransformerBase):
      TypeError: issubclass() arg 1 must be a class

    And I open the url "http://webdriverjs.christian-bromann.com/"            # None
    Then I expect that the url is "http://webdriverjs.christian-bromann.com/" # None
    And I expect that the url is not "http://google.com"                      # None

  Scenario: click on link                                          # features/myFeature.feature:13
    Given the title is not "two"                                   # ../../../../../../usr/local/lib/python2.7/site-packages/behave_webdriver/steps/expectations.py:22 0.000s
      Traceback (most recent call last):
        File "/usr/local/lib/python2.7/site-packages/behave/model.py", line 1329, in run
          match.run(runner.context)
        File "/usr/local/lib/python2.7/site-packages/behave_webdriver/transformers.py", line 111, in run
          if transformer_class and (isinstance(transformer_class, partial) and issubclass(transformer_class.func, TransformerBase)) or issubclass(transformer_class, TransformerBase):
      TypeError: issubclass() arg 1 must be a class

    And I open the url "http://webdriverjs.christian-bromann.com/" # None
    When I click on the link "two"                                 # None
    Then I expect that the title is "two"                          # None

Failing scenarios:
  features/myFeature.feature:6  open URL
  features/myFeature.feature:13  click on link

0 features passed, 1 failed, 0 skipped
0 scenarios passed, 2 failed, 0 skipped
0 steps passed, 2 failed, 6 skipped, 0 undefined
Took 0m0.002s
spyoungtech commented 5 years ago

@mikelietz this is the other bug ( #69 ) I mentioned. The fix for this was released in v0.2.2 So you shouldn't run into this if using the latest version.

If you installed behave-webdriver with pip be sure to upgrade it like so

pip install --upgrade behave-webdriver
mikelietz commented 5 years ago

My mistake - I had only upgraded what I had downloaded, for the tests, not the installed module. Thanks and yes, it is now working.