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.
Related
when I write the command line in terminal
bench new-site site1.local
This Error Will shown
> Traceback (most recent call last):
File "/home/ubuntu/.local/bin/bench", line 8, in <module>
sys.exit(cli())
File "/home/ubuntu/bench/bench/cli.py", line 71, in cli
cmd_from_sys = get_cmd_from_sysargv()
File "/home/ubuntu/bench/bench/utils/__init__.py", line 554, in get_cmd_from_sysargv
if sys_argv.index(arg) == 0 and arg in Bench(".").apps:
File "/home/ubuntu/bench/bench/bench.py", line 67, in __init__
self.apps = BenchApps(self)
File "/home/ubuntu/bench/bench/bench.py", line 174, in __init__
self.initialize_apps()
File "/home/ubuntu/bench/bench/bench.py", line 281, in initialize_apps
self.apps.remove("frappe")
ValueError: list.remove(x): x not in list
Note I use EC2 On AWS Ubunto server
Can Any One Help With This Problem Please.
I tried to install many lib but no help with this problem
When working with luigi on Windows 10, the following error is sometimes thrown:
Traceback (most recent call last):
File "D:\Users\myuser\PycharmProjects\project\venv\lib\site-packages\luigi\worker.py", line 192, in run
new_deps = self._run_get_new_deps()
File "D:\Users\myuser\PycharmProjects\project\venv\lib\site-packages\luigi\worker.py", line 130, in _run_get_new_deps
task_gen = self.task.run()
File "project.py", line 15000, in run
data_frame = pd.read_excel(self.input()["tables"].open(),segment)
File "D:\Users\myuser\PycharmProjects\project\venv\lib\site-packages\pandas\io\excel.py", line 191, in read_excel
io = ExcelFile(io, engine=engine)
File "D:\Users\myuser\PycharmProjects\project\venv\lib\site-packages\pandas\io\excel.py", line 247, in __init__
self.book = xlrd.open_workbook(file_contents=data)
File "D:\Users\myuser\PycharmProjects\project\venv\lib\site-packages\xlrd\__init__.py", line 115, in open_workbook
zf = zipfile.ZipFile(timemachine.BYTES_IO(file_contents))
File "C:\Python27\lib\zipfile.py", line 793, in __init__
self._RealGetContents()
File "C:\Python27\lib\zipfile.py", line 862, in _RealGetContents
raise BadZipfile("Bad magic number for central directory")
BadZipfile: Bad magic number for central directory
This error seems to only happen when working on Windows, and happens more frequently when a task requires to access the same file more than once in the same task, or is used by different tasks as a Target even when there are no parallel workers running. Code runs without errors on Linux.
Has anyone else experienced this behavior?
I'm trying to create pandas DataFrames from Excel file sheets but I get a BadZipFile error instead sometimes.
ERROR IS :
Traceback (most recent call last):
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 58, in load
dependencies, libzbar = load_objects(Path(''))
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 50, in load_objects
deps = [
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 51, in <listcomp>
cdll.LoadLibrary(str(directory.joinpath(dep)))
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'libiconv.dll' (or one of its dependencies). Try using the full path with constructor syntax.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "P:\Prashant\CPP Project Planning\Rooturaj CPP PRoject\Attendance\attend.py", line 3, in <module>
from pyzbar .pyzbar import decode
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\wrapper.py", line 151, in <module>
zbar_version = zbar_function(
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\wrapper.py", line 148, in zbar_function
return prototype((fname, load_libzbar()))
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\wrapper.py", line 127, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\zbar_library.py", line 54, in load_objects
libzbar = cdll.LoadLibrary(str(directory.joinpath(fname)))
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 452, in LoadLibrary
return self._dlltype(name)
File "C:\Users\kalep\AppData\Local\Programs\Python\Python39\lib\ctypes\__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
FileNotFoundError: Could not find module 'P:\Prashant\Python\Attendance\lib\site-packages\pyzbar\libzbar-64.dll' (or one of its dependencies). Try using the full path with constructor syntax.
I am creating project on attendance system using QR Code scanning and I use Python to create it.
I used all needed libraries in the program
like, cv2, numpy, pybase64, pyzbar.
But I am getting this above Error in the Pyzbar.
I got solution for this issue. I was facing similar issue just installed Visual C++ 64 bit version on my computer and restarted. Choose between vcredist_x86.exe or vcredist_x64.exe based on your machine.
https://www.microsoft.com/en-us/download/confirmation.aspx?id=40784. Hope this solves your issue as well.
I try to print a ticket in a thermal printer. I use module escpos
but when I run the script in Windows it sends me the following error
Traceback (most recent call last):
File "C:\Users\Angel\Desktop\Escritorio\impreimer.py", line 5, in <module>
Epson = printer.Usb(0x1a86,0x7584,1)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\escpos\printer.py", line 51, in __init__
self.open()
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\escpos\printer.py", line 68, in open
self.device.detach_kernel_driver(0)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\usb\core.py", line 1077, in detach_kernel_driver
interface)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\site-packages\usb\backend\libusb0.py", line 606, in detach_kernel_driver
_check(_lib.usb_detach_kernel_driver_np(dev_handle, intf))
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "C:\Users\Angel\AppData\Local\Programs\Python\Python36\lib\ctypes\__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'usb_detach_kernel_driver_np' not found
[Finished in 0.5s with exit code 1]
and this is my code:
import sys
from escpos import *
pr = printer.Usb(0x1a86,0x7584)
How can i fix this?
try this.
pr = printer.Usb(0x1a86,0x7584, interface=0, in_ep=0x82, out_ep=0x02)
if you are using Windows you need use programs like zadig or LibusbK and install filters.
https://zadig.akeo.ie/
http://libusbk.sourceforge.net/UsbK3/index.html
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