KeyError: 'browser' with Splinter and Behaving automated testing - python

I followed the instructions here: http://shon.github.io/2014/06/19/ui_testing_and_bdd.html about setting up Splinter with Behaving to run automated tests. I'm able to run a test successfully, but at the end of the test, it throws an error saying:
KeyError: 'browser'
and it won't continue testing any additional feature files. I'm pretty new to python and need some help in troubleshooting this.
Exception KeyError: 'browser'
Traceback (most recent call last):
File "/usr/local/bin/behave", line 11, in <module> sys.exit(main())
File "/Library/Python/2.7/site-packages/behave/__main__.py", line 109, in main
failed = runner.run()
File "/Library/Python/2.7/site-packages/behave/runner.py", line 672, in run
return self.run_with_paths()
File "/Library/Python/2.7/site-packages/behave/runner.py", line 693, in run_with_paths
return self.run_model()
File "/Library/Python/2.7/site-packages/behave/runner.py", line 483, in run_model
failed = feature.run(self)
File "/Library/Python/2.7/site-packages/behave/model.py", line 523, in run
failed = scenario.run(runner)
File "/Library/Python/2.7/site-packages/behave/model.py", line 867, in run
runner.run_hook('before_scenario', runner.context, self)
File "/Library/Python/2.7/site-packages/behave/runner.py", line 405, in run_hook
self.hooks[name](context, *args)
File "features/environment.py", line 48, in before_scenario
context.browser = default_browser
File "/Library/Python/2.7/site-packages/behave/runner.py", line 223, in __setattr__
record = self._record[attr]
KeyError: 'browser'

I found the issue. It is related to the Feature file structure. The Feature file was missing:
Background:
Given a browser
This also required changes to the environment.py file based on the info here: https://github.com/ggozad/behaving

Related

Robot framework [ ERROR ] Unexpected error: IOError: [Errno 0] Error

I have this weird error that I have never seen before. I ran an RF automation regression test using Chrome and after a while, I got this error which basically stops the test execution and does not provide any test results.
I also noticed this new text line that I haven't seen before during text execution:
DevTools listening on
ws://127.0.0.1:12306/devtools/browser/df1c8bcc-867c-41bc-a9b4-c364bdfafec2
(The test scripts have been used before & passed without any issues)
W8-BENE date format - ddMMMMMyyyyDot :: This is to test the differ...
DevTools listening on
ws://127.0.0.1:12537/devtools/browser/6d32afb6-90f2-46d4-a18a-001fa61d2444
[ ERROR ] Unexpected error: IOError: [Errno 0] Error Traceback (most
recent call last): File
"c:\python27\lib\site-packages\robot\utils\application.py", line 83,
in _execute
rc = self.main(arguments, **options)
File "c:\python27\lib\site-packages\robot\run.py", line 445, in main
result = suite.run(settings)
File "c:\python27\lib\site-packages\robot\running\model.py", line
248, in run
self.visit(runner)
File "c:\python27\lib\site-packages\robot\model\testsuite.py", line
161, in visit
visitor.visit_suite(self)
File "c:\python27\lib\site-packages\robot\model\visitor.py", line
87, in visit_suite
suite.tests.visit(self)
File "c:\python27\lib\site-packages\robot\model\itemlist.py", line
76, in visit
item.visit(visitor)
File "c:\python27\lib\site-packages\robot\model\testcase.py", line
74, in visit
visitor.visit_test(self)
File "c:\python27\lib\site-packages\robot\running\runner.py", line
151, in visit_test
result)
File "c:\python27\lib\site-packages\robot\running\runner.py", line
182, in _run_teardown
exception = self._run_setup_or_teardown(teardown)
File "c:\python27\lib\site-packages\robot\running\runner.py", line
201, in _run_setup_or_teardown
StepRunner(self._context).run_step(data, name=name)
File "c:\python27\lib\site-packages\robot\running\steprunner.py",
line 57, in run_step
return runner.run(step, context)
File
"c:\python27\lib\site-packages\robot\running\librarykeywordrunner.py",
line 56, in run
return return_value File "c:\python27\lib\site-packages\robot\running\statusreporter.py", line
54, in exit
context.end_keyword(result)
File "c:\python27\lib\site-packages\robot\running\context.py", line
179, in end_keyword
self.output.end_keyword(keyword)
File "c:\python27\lib\site-packages\robot\output\output.py", line
65, in end_keyword
LOGGER.end_keyword(kw)
File "c:\python27\lib\site-packages\robot\output\logger.py", line
195, in end_keyword
logger.end_keyword(keyword)
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
62, in end_keyword
self._writer.keyword_marker(kw.status)
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
136, in keyword_marker
self._clear_status()
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
124, in _clear_status
self._write_info()
File
"c:\python27\lib\site-packages\robot\output\console\verbose.py", line
90, in _write_info
self._stdout.write(self._last_info)
File
"c:\python27\lib\site-packages\robot\output\console\highlighting.py",
line 51, in write
self.stream.write(console_encode(text, stream=self.stream))
W8-BENE date format - ddMMMMMyyyyDot :: This is to test the differ...
C:\Development\robot-scripts\WebApp>
Has anyone had the same issue? I can't seem to find any solution. I uninstalled and reinstalled everything even update all the web drivers.
I had the same error after update to WIN 10. Just did fresh python install and it works fine for me. also look here: https://github.com/robotframework/robotframework/issues/2709

Error for Next button in pywinauto using python

I have to currently install windows application, create a new database etc almost everyday when testing the Windows desktop software builds that I get.
To make this job easier, I've decided to use python with pywinauto to automate this process.
Currently I was just trying to write a sample script to automate just another application. Following is my code:
from pywinauto.application import Application
app = Application().start(r"E:\New\any-video-converter.exe -a -n -y -- arguments")
dlg=app['Setup - Any Video Converter Professional']
Now I wanted to click on the 'Next >' button on the setup so I added the following to my code:
app.dlg.Next.Click()
But I get the following error message:
Traceback (most recent call last): File
"C:\Python34\lib\site-packages\pywinauto\application.py", line 243, in
__resolve_control
criteria)
File "C:\Python34\lib\site-packages\pywinauto\timings.py", line 424, in
wait_until_passes
raise err pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<pyshell#3>", line 1, in
<module>
app.dlg.NextButton.ClickInput()
File "C:\Python34\lib\site-packages\pywinauto\application.py", line 349, in
__getattribute__
ctrls = self.__resolve_control(self.criteria)
File "C:\Python34\lib\site-packages\pywinauto\application.py", line 246, in
__resolve_control
raise e.original_exception
File "C:\Python34\lib\site-packages\pywinauto\timings.py", line 402, in
wait_until_passes
func_val = func(*args)
File "C:\Python34\lib\site-packages\pywinauto\application.py", line 188, in
__get_ctrl
dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
File "C:\Python34\lib\site-packages\pywinauto\findwindows.py", line
84, in find_element
elements = find_elements(**kwargs)
File "C:\Python34\lib\site-packages\pywinauto\findwindows.py", line 294, in
find_elements
elements = findbestmatch.find_best_control_matches(best_match, wrapped_elems)
File "C:\Python34\lib\site-packages\pywinauto\findbestmatch.py", line 534, in
find_best_control_matches
raise MatchError(items = name_control_map.keys(), tofind = search_text)
pywinauto.findbestmatch.MatchError: Could not find 'dlg' in 'dict_keys([])'
Here is the snippet of the UI of the installer: Sample installer UI
I can't understand what's going wrong here. Any help would be appreciated.

libvpx KeyError for webrtc

i am generating project of webrtc using gyp & while generating things, i got following error:
File "/home/rtcdev/Nishant/src/webrtc/build/gyp_webrtc", line 102, in
gyp_rc = gyp.main(args) File "/home/rtcdev/Nishant/src/tools/gyp/pylib/gyp/init.py", line 526,
in main
return gyp_main(args) File "/home/rtcdev/Nishant/src/tools/gyp/pylib/gyp/init.py", line 502,
in gyp_main
params, options.check, options.circular_check) File "/home/rtcdev/Nishant/src/tools/gyp/pylib/gyp/init.py", line 129,
in Load
params['parallel'], params['root_targets']) File "/home/rtcdev/Nishant/src/tools/gyp/pylib/gyp/input.py", line 2756, in
Load
RemoveLinkDependenciesFromNoneTargets(targets) File "/home/rtcdev/Nishant/src/tools/gyp/pylib/gyp/input.py", line 1501, in
RemoveLinkDependenciesFromNoneTargets
if targets[t].get('variables', {}).get('link_dependency', 0): KeyError: 'third_party/libvpx/libvpx.gyp:libvpx_obj_int_extract#host'
Question:
i am not getting what this error want to tell as well as How to overcome from this error?

Searching for a string with Web.py

I'm trying to build a python function with web.py and SQLite that will allow users to search for a given string within a description field and will return all matching results.
Right now I've gotten to the below function, which works but only if the input is an exact match.
def getItem(params, max_display):
query_string = 'SELECT * FROM items WHERE 1=1'
description = params['description']
if params['description']:
query_string = query_string + ' AND description LIKE $description'
result = query(query_string, {
'description': params['description']
I've tried to implement this feature with LIKE "%$description%"' , however I keep getting the below web.py error.
Traceback (most recent call last):
File "lib/web/wsgiserver/__init__.py", line 1245, in communicate
req.respond()
File "lib/web/wsgiserver/__init__.py", line 775, in respond
self.server.gateway(self).respond()
File "lib/web/wsgiserver/__init__.py", line 2018, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
File "lib/web/httpserver.py", line 306, in __call__
return self.app(environ, xstart_response)
File "lib/web/httpserver.py", line 274, in __call__
return self.app(environ, start_response)
File "lib/web/application.py", line 279, in wsgi
result = self.handle_with_processors()
File "lib/web/application.py", line 249, in handle_with_processors
return process(self.processors)
File "lib/web/application.py", line 246, in process
raise self.internalerror()
File "lib/web/application.py", line 478, in internalerror
return debugerror.debugerror()
File "lib/web/debugerror.py", line 305, in debugerror
return web._InternalError(djangoerror())
File "lib/web/debugerror.py", line 290, in djangoerror
djangoerror_r = Template(djangoerror_t, filename=__file__, filter=websafe)
File "lib/web/template.py", line 846, in __init__
code = self.compile_template(text, filename)
File "lib/web/template.py", line 926, in compile_template
ast = compiler.parse(code)
File "/Users/sokeefe/homebrew/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 51, in parse
return Transformer().parsesuite(buf)
File "/Users/sokeefe/homebrew/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py", line 128, in parsesuite
return self.transform(parser.suite(text))
AttributeError: 'module' object has no attribute 'suite'
Any thoughts on what might be going wrong with this function?
Thanks in advance!
What do you think is going on with parser.py?
Here is the relevant portion of the error message:
File
"/Users/sokeefe/homebrew/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/compiler/transformer.py",
line 128, in parsesuite
return self.transform(parser.suite(text)) AttributeError: 'module' object has no attribute 'suite'
So, somewhere there is a file called parser.py, which defines a function called suite(), which is used by some library code that executes when your program executes. But because you named one of your files parser.py, when the library code executes, python searches for a file named parser.py, and python found your file first, and there was no function named suite() in your file.

Failed to execute Augustus PMML Gaslog Example. Need help to debug

I ran command testing the Gaslog example of Augutus:
Augustus consumer_config.xcfg
But got following error:
Traceback (most recent call last):
File "/usr/local/bin/Augustus", line 171, in <module>
main(config)
File "/usr/local/lib/python2.7/dist-packages/augustus/engine/mainloop.py", line 532, in main
mainLoop = MainLoop(configuration, dataStream=dataStream, rethrowExceptions=rethrowExceptions)
File "/usr/local/lib/python2.7/dist-packages/augustus/engine/mainloop.py", line 150, in __init__
self.model = xmlbase.loadfile(fileLocation, pmml.X_ODG_PMML, lineNumbers=True)
File "/usr/local/lib/python2.7/dist-packages/augustus/core/xmlbase.py", line 1628, in loadfile
return load(file(fileName), base, validation, dropSpecial, lineNumbers)
File "/usr/local/lib/python2.7/dist-packages/augustus/core/xmlbase.py", line 1807, in load
parser.parse(stream)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 107, in parse
xmlreader.IncrementalParser.parse(self, source)
File "/usr/lib/python2.7/xml/sax/xmlreader.py", line 123, in parse
self.feed(buffer)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 210, in feed
self._parser.Parse(data, isFinal)
File "/usr/lib/python2.7/xml/sax/expatreader.py", line 307, in end_element
self._cont_handler.endElement(name)
File "/usr/local/lib/python2.7/dist-packages/augustus/core/xmlbase.py", line 1728, in endElement
raise XMLValidationError("%sXMLValidationError: %s." % (stacktrace, str(err)))
augustus.core.xmlbase.XMLValidationError: Below is a traceback to the line that caused the actual exception.
File "/usr/local/lib/python2.7/dist-packages/augustus/core/xmlbase.py", line 1721, in endElement
last.validate(recurse=False, exception=True)
File "/usr/local/lib/python2.7/dist-packages/augustus/core/xmlbase.py", line 872, in validate
self.xsd.validate(self)
File "/usr/local/lib/python2.7/dist-packages/augustus/core/xmlbase.py", line 1579, in validate
xml.post_validate()
File "/usr/local/lib/python2.7/dist-packages/augustus/core/pmml41.py", line 1656, in post_validate
pmmlApply.top_validate_transformationDictionary(self.transformationDictionary)
File "/usr/local/lib/python2.7/dist-packages/augustus/core/pmml41.py", line 7092, in top_validate_transformationDictionary
raise PMMLValidationError("Apply function \"%s\" not recognized (not built-in and not user-defined)" % function)
XMLValidationError: Apply function "formatDateTime" not recognized (not built-in and not user-defined).
Ref:
Example I was trying: https://github.com/codersofthedark/augustus/tree/master/augustus-examples/gaslog/introductory
Augustus: https://code.google.com/p/augustus/
I got the same error. I'm not an expert at Augustus, but it looks the model file, "example_model.pmml" has the function, "formatDateTime", spelled wrong in two places. It should be "formatDatetime" (i.e., "time" should start with a lowercase "t"). When I made that correction, the example ran and produced output in the results directory.

Categories

Resources