ggozad / behaving Goto Github PK
View Code? Open in Web Editor NEWBehavior-Driver-Development for multi-user web/email/sms applications
License: Other
Behavior-Driver-Development for multi-user web/email/sms applications
License: Other
Having the ability to template parameters and data using jinja is very useful
I'm using the behave_http which implements this
https://github.com/mikek/behave-http/blob/master/behave_http/utils.py#L18
with this I can target multiple deployments for example, and also handle states without having to write duplicate feature definitions. What are your thoughts ?
behaving/web/steps/forms.py
does not provide a way to fill in text containing double quotes. This is particularly relevant for text areas.
It might be beneficial to provide a variant I fill in "{name}" with
step that relies on context.text
, similar to behaving/personas/steps.py
I set "{key}" to
.
Is there an option to pass parameters (--ignore-ssl-errors=true) to phantomjs ?
tried it with a script, but phantomjs will not shutdown after completing the steps.
/opt/phantomjs/phantomjs $@ --ignore-ssl-errors=true
We are starting to use behaving a lot and have a few changes to the built in steps that would be worthwhile making.
We have had to implement our own steps to do the above but it would be nice to use the standard steps instead.
How do I use 'behaving' with behave's scenario outline and example tables? Right now any Given, When, Then statements with '<>' are skipped and not processed by 'behaving'. I get an error steps are not implemented.
Given I should see <heading_on_page>
When I search for <query_in_search_field>
And I should see <text_in_search_result> within 15 seconds
And I click the link with text that contains <title>
Then I should see <text_in_document> within 10 seconds
If I copy the relevant steps from behaving into my own step file and remove the double quotes around the variable in the decoration, my outline passes.
@given(u'I should see {text}')
# @step(u'I should see "{text}"')
# @persona_vars
def should_see(context, text):
assert context.browser.is_text_present(text), u'Text not found'
Tools such as Black and Pre-commit have repository badges. I haven't been able to find one for Behave, does one exist?
I am using steps from a 3rd party library (behave_http)
Now I need to modify the behaviour of these steps specifically for my project
So in my steps I need a way to override the steps defined in the library.
Currently it errors out with an exception about duplicate step definition
I am using behaving for auto-testing. I need to clear the text in a input box so I can check the error message. I did this:
When I fill in "field-name" with ""
However I got this error:
You can implement step definitions for undefined steps with these snippets:
@when(u'I fill in "field-name" with ""')
def impl(context):
assert False
Set input box to empty is useful, hope this can be allowed.
Hello!
I was wondering if you think it'd be better if the format of the screenshot's filename start with the datetime. This might be a nitpick, but in my opinion, failing tests' screenshots would be easier to find if the files are sorted by name on explorer/finder. I'll be happy to make a PR if you think this is a good idea.
Thoughts? 😄
I want to use headless browser(firefox/chrome),how do i configure it?
eg:
Given a headless browser
This is my traceback:
Traceback (most recent call last):
File "/Users/galuszkak/Projects/virtuals/evmgmt/lib/python2.7/site-packages/behave/model.py", line 1173, in run
match.run(runner.context)
File "/Users/galuszkak/Projects/virtuals/evmgmt/lib/python2.7/site-packages/behave/model.py", line 1589, in run
self.func(context, *args, **kwargs)
File "/Users/galuszkak/Projects/virtuals/evmgmt/lib/python2.7/site-packages/behaving/personas/persona.py", line 53, in replace
value = context.persona.get_value(var)
AttributeError: 'dict' object has no attribute 'get_value'
splinter.Browser.attach_file(name, path) needs an absolute path, not a relative path.
The fix is as simple as inserting the following before line 184 in behaving\web\steps\forms.py
def i_attach(context, name, path):
if not os.path.exists(path):
path = os.path.join(context.attachment_dir, path)
if not os.path.exists(path):
assert False
path = os.path.abspath(path)
context.browser.attach_file(name, path)
I can do a pull request if you like as well
I've started using PhantomJS as my browser under behaving.web
and I'm noticing
that it's leaving the process running after the behave run is finished. After a while,
I have a dozen background phantomjs processes each taking a 1/2G of memory each...
I don't know who's "fault" it is: behaving, behave, splinter, selenium, phantomjs etc.,
and it's unlikely to be behaving, but I thought I'd flag it so you can keep your eye
on it. If I have time, I'll try to look at the chain of execution and report back.
phantomjs 2.0.0 under Linux.
It seems to me that there is a missing wait_time=timeout argument to the code below.
@step(u'I should not see "{text}" within {timeout:d} seconds')
def should_not_see_within_timeout(context, text, timeout):
assert context.browser.is_text_not_present(text), u'Text was found'
The positive tests seems to be using it OK.
@step(u'I should see "{text}" within {timeout:d} seconds')
def should_see_within_timeout(context, text, timeout):
assert context.browser.is_text_present(text, wait_time=timeout), u'Text not found'
I've checked here that the wait_time can be used with the negative text present method.
This is realy a Request for Discussion, but I thought I'd post it here rather than sending you email,
so that the discussion can be followed by others.
Firstly, thank-you very much for writing behaving - it's saved me huge amounts of my time.
Secondly, I appreciate the way that you used Python namespace packages for your components,
and I would like to propose that as the way forward for the behave community to package up step libraries in a way for making them work together. And I like the idea of the behaving namespace being completely independent from the behave base.
I've done a proof of concept package that plugs into the behaving.cmd namespace, which
will be a step library for the standard file manipulation commands. But I just cut and pasted your layout and namespace packaging so that it should "just work" alongside behaving. See the
README at https://github.com/lampmantech/behaving.cmd
Could I ask you to take a look at the package and layout and double check that I didn't
make any mistakes in my cut and paste. I didn't bother with buildout, but perhaps travis should be put back in...
If you like the proof-of-concept, then we can suggest the layout and packaging to be the way forward for packaging step libraries. Then the behave community can work together without fragmentation and the havoc wrecked by entropy, and behaving.cmd
can replace the dormant https://github.com/behave/behave4cmd , ideally under the behave project.
I was following the docs, and added context.personas = PERSONAS
to before_all()
. This doesn't work for me, because in before_scenario()
context.personas = {}
empties the dict and there are no personas available for the Given step.
Either I'm doing something wrong, or the personas dict shouldn't be emptied, or context.personas = PERSONAS
should be assigned to context in before_scenario()
instead - this works.
Hi,
Any idea how to escape the quotes needed(?) to parse the variables? Tried {}/:[] with no result.
Example:
Step "#hello_$randomday_$randommonth_$randomyear" - the variables are not parsed
Step " #hello_"$randomday" _ "$randommonth" _ "$randomyear" " - the variables are parsed but I got something like this - #hello_ "1" _ "July" _"2015"
Thank you for your help with this,
Bogdan
Why does given_a_persona
in behaving/personas/steps.py
reuse the persona name as the name of the browser to load? It makes no sense to me.
Hello,
The link http://pythonhosted.org/behave/ is not available. Could you please replace it with a working link?
With new splinter test are failing because there isn't now method: 'switch_to_window'. I will try to fix that.
There is logic in behaving/web/steps/links.py
to handle single quotes (which will disrupt XPath) within the specified link text, but this logic is not present in the 'I press "{name"}' step in behaving/web/steps/forms.py
, so usage like
I press "Dave's Books"
will fail with "Element not found".
This is a Request for Enhancement, but also the identification of a broader issue across behaving namespace packages.
With behaving.web
I can select the browser that will be used from a feature/step.
But in some cases, I need to configure the browser that will be called by splinter
.
I may need to set firefox up with a profile, or instruct PhotomJS about the cache.
Unforunately the call that splinter makes takes very different call signatures for each brower so there is no way to do this in a generalized way. E.g. for firefox:
def __init__(self, profile=None, extensions=None, user_agent=None, profile_preferences=None, fullscreen=False, wait_time=2):
For PhantomJS
def __init__(self, user_agent=None, load_images=True, desired_capabilities=None, wait_time=2, custom_headers={}, **kwargs)
You could do this by individualized steps to parameterize each browser, but even then it would get messy, as some of these parameters are not just strings, but dictionaries.
This is a generic problem of how to configure the backend, and I think needs a generic solution. A generic solution would be then adopted by all of the packages in the
behaving namespace so that we all stay on the same page.
If you look at the approach we have taken in:
https://github.com/lampmantech/behaving.trytond
you'll see an environment.cfg
file in the src/behaving/tests/features
directory alongside the environment.py
to parameterize the steps. This can be used
to parameterize the steps, and the reason we used configobj
rather than
configparser
is that it gracefully handles dictionaries or JSON. I think that something like this will be needed by behaving to parameterize the arguments to the browser instances that are created by splinter, or any other back end, like a server.
If our approach works for you, all we need to do is sync some naming conventions.
For example the section names should be the behaving namespace names,
so that we all could use the same environment.cfg
file, and any client-end use
of the environment.cfg
file would know that it could use any mix of all of
the possible behaving namespace packages. There may even be some common settings
in a [behaving]
sections: things like verbosity, or which debugger to call on error.
i have gmail account in testing
where and how i should set config for imap or pop3 config that let behaving connect and check for new mail
i can't find it in guide there is only one line about configuration
context.mail_path = os.path.join(os.path.dirname(mypackage.file), '../../var/mail/')
this like use /var/mail old style linux internal mailing system
please help about this
Maybe should be https://github.com/cobrateam/splinter ?
error: uncaptured python exception, closing channel <smtpd.SMTPChannel connected 127.0.0.1:59782 at 0x7f0c411f0898> (<class 'TypeError'>:process_message() got an unexpected keyword argument 'mail_options'
method signature needs two additional parameters mail_options and rcpt_options
possibly other changes as well
This is because window does not get focus.
Dear,
I´m new with behaving. Congrats for the hard work
I´m using:
@step(u'I should see "{text}" within {timeout:d} seconds')
from:
https://github.com/ggozad/behaving/blob/master/src/behaving/web/steps/basic.py
I receive the error:
'WebDriver' object has no attribute 'is_text_present'
could you check it please?
Hi, I was using click_link_in_email
step and seems like you are not encoding the payload there as in should_receive_email_containing_text
for example. Is it a bug, or I'm using it wrong?
https://pypi.python.org/pypi/behaving/ lists behaving 1.5.0 as deployed and available, however a
$ pip install behaving==1.5.0
fails with a 404 not found, with the logs saying it looked for the download in https://pypi.python.org/simple/behaving/ which only lists downloads up to behaving 1.4.1
Additionally, https://pypi.python.org/pypi/behaving/1.4.1 has a green download button, whereas https://pypi.python.org/pypi/behaving/1.5.0 is missing the button.
We're trying to run file upload tests on Python 3.9, which means we need to use Selenium 4 in order to fix SeleniumHQ/selenium#8762, but there doesn't seem to be any Behaving version that we can use.
AttributeError: 'dict' object has no attribute 'click'
Hello,
Given selenium 3 is not going to be supported (see e.g. discussion on SeleniumHQ/selenium#8762), could you please tell us if you are planning to support selenium 4 and if so, if you have a roadmap?
Many thanks!
Tests on Travis doesn't work...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.