I learn from blog (http://technapstar.blogspot.fi/2014/07/automation-with-pywinauto.html) about starting google chrome and input a web address by pywinauto as the following way:
Python 3.6.1rc1 (v3.6.1rc1^0:e0fbe5feee4f9c00f09eb9659c2182183036261a, Mar 4 2017, 20:00:12) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import pywinauto
>>> pywinauto.__version__
'0.6.2'
>>> from pywinauto.application import Application
>>> app = Application().start("chrome.exe")
Warning (from warnings module):
File "D:\Python\lib\site-packages\pywinauto\application.py", line 982
UserWarning)
UserWarning: 32-bit application should be automated using 32-bit Python (you use 64-bit Python)
>>> app.window_(title='New Tab')
<pywinauto.application.WindowSpecification object at 0x0000000002FFABE0>
>>> app.window_().TypeKeys('{F6}')
<pywinauto.controls.hwndwrapper.DialogWrapper object at 0x0000000004258320>
>>> app.window_().TypeKeys('{ESC}')
<pywinauto.controls.hwndwrapper.DialogWrapper object at 0x0000000004243518>
>>> app.window_().TypeKeys('www.google.com')
<pywinauto.controls.hwndwrapper.DialogWrapper object at 0x0000000004225D68>
>>> app.window_().TypeKeys('{ENTER}')
<pywinauto.controls.hwndwrapper.DialogWrapper object at 0x00000000042436D8>
>>>
However, when I try to start another google chrome window with the same way, I meet the following error.
>>> app1 = Application().start("chrome.exe")
Warning (from warnings module):
File "D:\Python\lib\site-packages\pywinauto\application.py", line 982
UserWarning)
UserWarning: 32-bit application should be automated using 32-bit Python (you use 64-bit Python)
>>> app1.window_(title='New Tab')
<pywinauto.application.WindowSpecification object at 0x0000000004243470>
>>> app1.window_().TypeKeys('{F6}')
Traceback (most recent call last):
File "D:\Python\lib\site-packages\pywinauto\application.py", line 243, in __resolve_control
criteria)
File "D:\Python\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#11>", line 1, in <module>
app1.window_().TypeKeys('{F6}')
File "D:\Python\lib\site-packages\pywinauto\application.py", line 365, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "D:\Python\lib\site-packages\pywinauto\application.py", line 246, in __resolve_control
raise e.original_exception
File "D:\Python\lib\site-packages\pywinauto\timings.py", line 402, in wait_until_passes
func_val = func(*args)
File "D:\Python\lib\site-packages\pywinauto\application.py", line 188, in __get_ctrl
dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
I google a bit, but could not find the answers. Can somebody suggest what is the best way to operate google chrome by pywinauto? or pywinauto is not a proper tool to operate google chrome at the moment.
[EDIT] Still not working by following Vasily's student sample code, see here:
>>> app = Application(backend='uia');
>>> app.start('chrome.exe --force-renderer-accessibility')
<pywinauto.application.Application object at 0x00000000045D80B8>
>>> app.window().type_keys('{F6}')
<pywinauto.controls.uiawrapper.UIAWrapper object at 0x00000000045D8AC8>
So far it is ok, but when I try to have another chrome browser, I meet following error:
>>> app1 = Application(backend='uia');
>>> app1.start('chrome.exe --force-renderer-accessibility')
<pywinauto.application.Application object at 0x0000000003324F28>
>>> app1.window().type_keys('{F6}')
Traceback (most recent call last):
File "D:\Python\lib\site-packages\pywinauto\application.py", line 243, in __resolve_control
criteria)
File "D:\Python\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#18>", line 1, in <module>
app1.window().type_keys('{F6}')
File "D:\Python\lib\site-packages\pywinauto\application.py", line 365, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "D:\Python\lib\site-packages\pywinauto\application.py", line 246, in __resolve_control
raise e.original_exception
File "D:\Python\lib\site-packages\pywinauto\timings.py", line 402, in wait_until_passes
func_val = func(*args)
File "D:\Python\lib\site-packages\pywinauto\application.py", line 188, in __get_ctrl
dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
File "D:\Python\lib\site-packages\pywinauto\findwindows.py", line 87, in find_element
raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'backend': 'uia', 'process': 2832}
>>>