2

Overall my problem is I am trying to automate a Windows 10 application with WinnAppDriver and writing my automation in Python. There seems to be very little information on how to do this as most WinAppDriver examples are in Java (understandable...). But I BARELY know the basics of Python and nothing about Java. So...is there a book or video I'm missing? Specifically I installed everything (Python via VS Code) and actually got the Python sample Calculator test to run....then I had to restart my PC and I get the following error:

I apologize for being such a newbie.... I had learned basics of Python via videos so I could implement Sikulix automations and this worked great until I had to switch between computers....it is exceedingly easy to break Sikulix as it is resolution dependent. So...after looking around I decided to try to automate via WinAppDriver...within Python. Wow....I cannot find ANY books or videos on how to do this (since I barely am learning Python and know zero Java). Any help would be appreciated and I WILL prove I will spend the time to watch recommended videos or study recommended books / texts. Thanks so much in advance...

[Running] python -u "c:\Users\bartc\Downloads\WinAppDriver-master\WinAppDriver-master\Samples\Python\CasaCharm 1.py" ERROR

======================================================================

ERROR: setUpClass (main.SimpleCalculatorTests)

Traceback (most recent call last): File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 160, in _new_conn (self._dns_host, self.port), self.timeout, **extra_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 80, in create_connection raise err File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\connection.py", line 70, in create_connection sock.connect(sa) ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 603, in urlopen chunked=chunked) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 355, in _make_request conn.request(method, url, **httplib_request_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1229, in request self._send_request(method, url, body, headers, encode_chunked) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1275, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1224, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 1016, in _send_output self.send(msg) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\http\client.py", line 956, in send self.connect() File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 183, in connect conn = self._new_conn() File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connection.py", line 169, in _new_conn self, "Failed to establish a new connection: %s" % e) urllib3.exceptions.NewConnectionError: : Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "c:\Users\bartc\Downloads\WinAppDriver-master\WinAppDriver-master\Samples\Python\CasaCharm 1.py", line 31, in setUpClass desired_capabilities= desired_caps) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\appium\webdriver\webdriver.py", line 144, in init proxy File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in init self.start_session(capabilities, browser_profile) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\appium\webdriver\webdriver.py", line 219, in start_session response = self.execute(RemoteCommand.NEW_SESSION, parameters) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute response = self.command_executor.execute(driver_command, params) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute return self._request(command_info[0], url, body=data) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 397, in _request resp = self._conn.request(method, url, body=body, headers=headers) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\request.py", line 72, in request **urlopen_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\request.py", line 150, in request_encode_body return self.urlopen(method, url, **extra_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\poolmanager.py", line 326, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen **response_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen **response_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 670, in urlopen **response_kw) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\connectionpool.py", line 641, in urlopen _stacktrace=sys.exc_info()[2]) File "C:\Users\bartc\AppData\Local\Programs\Python\Python37\lib\site-packages\urllib3\util\retry.py", line 399, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='127.0.0.1', port=4723): Max retries exceeded with url: /session (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10061] No connection could be made because the target machine actively refused it'))


Ran 0 tests in 6.470s

FAILED (errors=1)

[Done] exited with code=0 in 22.349 seconds

Bart Clark
  • 21
  • 1
  • 3
  • Ugh.... OK. So...after being stuck for three nights I finally figured out why the Python Calculator test was NOT running....: You have to actually run the WinAppDriver.exe so it is 'listening'.... What an embarrassing first question. OK. IF any of you have ANY suggestions on where to look for additional instruction / examples of automating Windows 10 Applications via Python and WinAppDriver...please forward...as I am still only finding examples of how to employ WinAppDriver via Java.... ( yes I understand it is written in Java, but supposedly you can control the automations with Python). – Bart Clark Sep 12 '19 at 00:30
  • We all go through such mistakes, don't worry ;-). Is coding your scripts in Python a prerequisite? Since you're still learning python, maybe it's better to consider a language where winappdriver is documented more thoroughly? I'm doing my ui test scripts in C#. Since C#, .net framework, winappdriver and VS Code are Microsoft products, it made more sense to me. It's just a suggestion based on personal opinion though :-). I would also suggest to first learn the basics of the language of your choosing before moving on to winappdriver. – PixelPlex Sep 16 '19 at 12:26

1 Answers1

1

My company uses RobotFramework for automation testing which is built on top of python so I understand your pain on finding examples. I built out a testing library for Desktop automation using winappdriver and seeing as this is built on top of python you may find the source code useful

The library extends robotframework-appiumlibrary for many of the base functionalities so their source code may be of use to you as well.

Alternatively if you are not well versed in python it may be worth looking into robotframework and use the zoomba library I provided. Robotframework is very easy to pick up without any python knowledge.