Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: macOS implementation of keyboard, mouse, AxElementInfo and Application #841

Open
wants to merge 59 commits into
base: macos
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
1131c64
Input modules implementation:
zemtsov-artem Nov 20, 2018
a6e1c65
Comments fixes
azemtsov Dec 27, 2018
1dec7be
mac os application base implementation
azemtsov Jun 2, 2019
fd0c967
added get app instance by bundle method
zemtsov-artem Jun 2, 2019
f732946
hotfixes for application class
zemtsov-artem Jun 2, 2019
dbc9fda
implementation of connecting by bundle
Jun 2, 2019
1cfd0e6
Removed duplicated attribute for app instance
briaclg Jun 7, 2019
7efcd71
unittest for macos_application added, modification of the function start
briaclg Jun 19, 2019
b216dc1
Add Unittest application for macos, change of start in application ex…
briaclg Jun 19, 2019
92941f8
Make method start() more PEP-8 complaint
vasily-v-ryabov Jun 21, 2019
f22b129
added the element_info class
briaclg Jul 11, 2019
fea4658
application and test_application_macos formated on pep8 style
briaclg Jul 11, 2019
dc5bcea
corrected ax_element_info, added list of know control type, and creat…
briaclg Jul 12, 2019
c8d421a
got rid of _getattr, change in unittest
briaclg Jul 18, 2019
2ed35bd
Correction of comment in ax_element_info
briaclg Jul 19, 2019
a12f818
correction of start by name, flake files, added some untitest
briaclg Jul 24, 2019
fd4d789
correction in application, ax_element_info and their unitest
briaclg Aug 6, 2019
9050be6
Merge branch 'atspi' into mac_os_application
vasily-v-ryabov Aug 8, 2019
3e7499a
finish coverage
briaclg Aug 8, 2019
25290d8
Fix install commands on Linux (Travis CI).
vasily-v-ryabov Aug 8, 2019
03c8bef
Fix the rest of merge issues (Travis CI build).
vasily-v-ryabov Aug 8, 2019
d5445ed
Move method __iter__() back to BaseApplication.
vasily-v-ryabov Aug 8, 2019
16cd365
Fix mouse unit tests on Travis.
vasily-v-ryabov Aug 8, 2019
3fd9a54
Remove duplicated matrix items in Travis CI.
vasily-v-ryabov Aug 8, 2019
1027f01
Add missing import and try fixing keyboard tests on macOS.
vasily-v-ryabov Aug 8, 2019
97518a2
Fix the rest of merge issues, add keyboard imports on macOS.
vasily-v-ryabov Aug 9, 2019
eded6e0
Fix Python versions on macOS Travis CI build.
vasily-v-ryabov Aug 9, 2019
cb5f951
Get back to "generic" language on macOS.
vasily-v-ryabov Aug 9, 2019
ea65e6e
Fix path to new unit tests on macOS on Travis CI.
vasily-v-ryabov Aug 12, 2019
c76a091
Merge remote-tracking branch 'remotes/briac/mac_os_application' into …
vasily-v-ryabov Aug 12, 2019
9a113ae
Correction of application method and its unitest
briaclg Aug 12, 2019
b01d216
update to python3
briaclg Aug 12, 2019
1151b61
Merge remote-tracking branch 'remotes/briac/mac_os_application' into …
vasily-v-ryabov Aug 13, 2019
4843434
get rid of global var
briaclg Sep 15, 2019
40a46b7
Merge remote-tracking branch 'remotes/briac/mac_os_application' into …
vasily-v-ryabov Sep 15, 2019
0126998
Check comtypes presence more precisely.
vasily-v-ryabov Mar 11, 2020
882536b
Fix warnings, code style and other code smells for macOS.
vasily-v-ryabov Mar 11, 2020
d7345d2
Merge branch 'macos' into mac_os_application
vasily-v-ryabov Mar 11, 2020
1fd0f4d
Code style fixes in macOS keyboard_helper.py.
vasily-v-ryabov Mar 11, 2020
2b8e1ac
Updated setup.py + added macos- requirements.file
zemtsov-artem Feb 11, 2020
bf6a5cb
Removed unnecessary macos-req file.
zemtsov-artem Feb 15, 2020
8e1eaf8
Removed duplicated package
zemtsov-artem Feb 15, 2020
5e9b0f4
Applied comments
zemtsov-artem Feb 27, 2020
e682e49
Applied comments
zemtsov-artem Mar 5, 2020
dc7ed19
Rebased onto latest code + fixed Codacy comments
zemtsov-artem Apr 19, 2020
f42d94b
Updated test apps + travis configuration files.
zemtsov-artem Oct 27, 2019
73214cf
macOS application updates.
zemtsov-artem Oct 27, 2019
622a47c
Extracted cache updating to macos_functions
zemtsov-artem Oct 27, 2019
7b2425e
Updated bundle id of test application
zemtsov-artem Dec 1, 2019
a8b8a01
Updated the travis yml script
zemtsov-artem Feb 27, 2020
e582afd
Removed unnecessary configs
zemtsov-artem Mar 5, 2020
bdfbd9d
Fixed code style, eliminated the wildcard imports, removed unnecessar…
zemtsov-artem Apr 19, 2020
d207c2d
Fixed application and element info tests.
zemtsov-artem Apr 19, 2020
6bbfd49
Fixed code style for codacy
zemtsov-artem Apr 19, 2020
0b0be67
Merge pull request #12 from zemtsov-artem/azemtsov/mac_os_setup
vasily-v-ryabov Apr 20, 2020
9e455de
Merge pull request #11 from zemtsov-artem/azemtsov/mac_os_application
vasily-v-ryabov Apr 20, 2020
88a4847
Extracted common init+deinit logic to setup and teardown.
zemtsov-artem Apr 21, 2020
d649788
Merge pull request #13 from zemtsov-artem/azemtsov/macos_application_…
vasily-v-ryabov Apr 25, 2020
05f0b66
Override __iter__ method for derived Application classes.
vasily-v-ryabov May 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
175 changes: 119 additions & 56 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,72 +1,135 @@
sudo: required
dist: trusty
language: cpp
notifications:
email: false

# env:
# Run against all supported versions of Python (this environment variable is
# used further down the fetch an appropriate Python interpreter).
matrix:
include:
- os: osx
osx_image: xcode8
env: PYVER=2.7
language: generic
- os: osx
osx_image: xcode8
env: PYVER=3.5
language: generic
- os: osx
osx_image: xcode8
env: PYVER=3.6
language: generic
- os: linux
language: python
python: 2.7
# - os: linux
# language: python
# python: 3.3
- os: linux
language: python
python: 3.4
- os: linux
language: python
python: 3.5
- os: linux
language: python
python: 3.6

language: python

python:
#- "2.6"
- "2.7_with_system_site_packages"
- "3.3"
- "3.4_with_system_site_packages"
- "3.5"
- "3.6"
os:
- linux
before_install:
- sudo add-apt-repository -y ppa:beineri/opt-qt58-trusty
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo add-apt-repository -y ppa:beineri/opt-qt58-trusty; fi

install:
- pip install python-xlib codecov coverage
# Install 'pyenv': a utility for downloading and switching between multiple
# Python interpreters on the same system.
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then git clone https://github.com/yyuu/pyenv.git ~/.pyenv; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then PYENV_ROOT="$HOME/.pyenv"; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then PATH="$PYENV_ROOT/bin:$PATH"; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then eval "$(pyenv init -)"; fi
# Install the latest release of the specified Python version using pyenv.
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then PYVER="$(pyenv install --list | grep -E "^\\s*$PYVER" | sort -n -t. -k3 | tail -n1)"; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then pyenv install $PYVER; fi
# Make the newly installed version the default "python" command.
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then pyenv global $PYVER; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then python --version; fi
# Install PIP
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then curl -O https://bootstrap.pypa.io/get-pip.py; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then python get-pip.py --user; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then python -m pip install pip==9.0.3; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then python -m pip install six; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then pip install codecov coverage pyobjc; fi


# Linux dev dependencies:

- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then pip install python-xlib codecov coverage; fi
# All this dependencies only to build tests application. No real dependency of this packages
- sudo apt-get update
- sudo apt-get -y install at-spi2-core
- sudo apt-get install -qq qt58base;
- sudo apt-get -y install qt58declarative qt58tools
- sudo apt-get install xsel
- sudo apt-get install libgtk-3-dev libgtk2.0-dev
- sudo apt-get install -y python3-gi
- source /opt/qt58/bin/qt58-env.sh;
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get update; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get -y install at-spi2-core; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get install -qq qt58base; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get -y install qt58declarative qt58tools; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get install xsel; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get install libgtk-3-dev libgtk2.0-dev; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sudo apt-get install -y python3-gi; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then source /opt/qt58/bin/qt58-env.sh; fi

before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- sleep 3 # give xvfb some time to start
- xauth generate :99.0 . trusted
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then export DISPLAY=:99.0; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sh -e /etc/init.d/xvfb start; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then sleep 3; fi
# give xvfb some time to start;
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then xauth generate :99.0 . trusted; fi
# Clone test apps
- git init apps
- cd apps
- git remote add -f origin https://github.com/pywinauto/PywinautoTestapps/
- git config core.sparseCheckout true
- echo "MouseTester/source" >> .git/info/sparse-checkout
- echo "SendKeysTester/source" >> .git/info/sparse-checkout
- git pull origin master
# Build test apps
- cd MouseTester/source
- qmake
- make
- chmod a+x mousebuttons
- cp mousebuttons ../
- cd $TRAVIS_BUILD_DIR
- cd apps/SendKeysTester/source
- qmake
- make
- chmod a+x send_keys_test_app
- cp send_keys_test_app ../
- cd $TRAVIS_BUILD_DIR
- chmod a+x $TRAVIS_BUILD_DIR/apps/Gtk_samples/gtk_example.py
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then git init apps; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cd apps; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then git remote add -f origin https://github.com/pywinauto/PywinautoTestapps/; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then git config core.sparseCheckout true; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then echo "MouseTester/source" >> .git/info/sparse-checkout; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then echo "SendKeysTester/source" >> .git/info/sparse-checkout; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then git pull origin master; fi

# Build test apps on Linux
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cd MouseTester/source; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then qmake; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then make; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then chmod a+x mousebuttons; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cp mousebuttons ../; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cd $TRAVIS_BUILD_DIR; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cd apps/SendKeysTester/source; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then qmake; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then make; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then chmod a+x send_keys_test_app; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cp send_keys_test_app ../; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then cd $TRAVIS_BUILD_DIR; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then chmod a+x $TRAVIS_BUILD_DIR/apps/Gtk_samples/gtk_example.py; fi

# Install test apps on macOS
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then cd $TRAVIS_BUILD_DIR; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then cd apps/MouseTester/macos; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo hdiutil attach mousebuttons.dmg; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo cp -R /Volumes/mousebuttons/mousebuttons.app /Applications; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo hdiutil detach /Volumes/mousebuttons/; fi

- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then cd $TRAVIS_BUILD_DIR; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then cd apps/SendKeysTester/macos; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo hdiutil attach send_keys_test_app.dmg; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo cp -R /Volumes/send_keys_test_app/send_keys_test_app.app /Applications; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then sudo hdiutil detach /Volumes/send_keys_test_app/; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then cd $TRAVIS_BUILD_DIR; fi

script:
- coverage run -a --include=pywinauto/mouse.py pywinauto/unittests/test_mouse.py
- coverage run -a --include=pywinauto/linux/keyboard.py pywinauto/unittests/test_keyboard.py
- coverage run -a --include=pywinauto/linux/clipboard.py pywinauto/unittests/test_clipboard_linux.py
- coverage run -a --include=pywinauto/linux/application.py pywinauto/unittests/test_application_linux.py
- coverage run -a --source=pywinauto/linux,pywinauto/controls pywinauto/unittests/test_atspi_element_info.py
- coverage run -a --source=pywinauto/linux,pywinauto/controls pywinauto/unittests/test_atspi_wrapper.py
- coverage run -a --source=pywinauto/linux,pywinauto/controls pywinauto/unittests/test_atspi_controls.py
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then coverage run -a --include=pywinauto/mouse.py pywinauto/unittests/test_mouse.py; fi
- if [[ $TRAVIS_OS_NAME == 'osx' ]]; then coverage run -a --include=pywinauto/macos/keyboard_helper.py pywinauto/unittests/test_keyboard.py; fi
# Application and element info unit test are turned off due to we are not able to provide the accessibility permissions for testing on remote environment
# - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then coverage run -a --source=pywinauto/macos pywinauto/unittests/test_application_macos.py; fi
# - if [[ $TRAVIS_OS_NAME == 'osx' ]]; then coverage run -a --source=pywinauto/macos pywinauto/unittests/test_ax_element_info_macos.py; fi

- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --include=pywinauto/mouse.py pywinauto/unittests/test_mouse.py; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --include=pywinauto/linux/keyboard.py pywinauto/unittests/test_keyboard.py; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --include=pywinauto/linux/clipboard.py pywinauto/unittests/test_clipboard_linux.py; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --include=pywinauto/linux/application.py pywinauto/unittests/test_application_linux.py; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --source=pywinauto/linux,pywinauto/controls pywinauto/unittests/test_atspi_element_info.py; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --source=pywinauto/linux,pywinauto/controls pywinauto/unittests/test_atspi_wrapper.py; fi
- if [[ $TRAVIS_OS_NAME == 'linux' ]]; then coverage run -a --source=pywinauto/linux,pywinauto/controls pywinauto/unittests/test_atspi_controls.py; fi

after_success:
- codecov
Binary file added apps/MouseTester/macos/mousebuttons.dmg
Binary file not shown.
Binary file added apps/SendKeysTester/macos/send_keys_test_app.dmg
Binary file not shown.
24 changes: 22 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
pywin32
# Windows specific packages
#
pywin32 ;sys_platform == 'win32'

# macOS specific packages
#
pyobjc-core==5.3 ; sys_platform == 'darwin'
pyobjc-framework-AppleScriptObjC==5.3 ; sys_platform == 'darwin'
pyobjc-framework-ApplicationServices==5.3 ; sys_platform == 'darwin'
pyobjc-framework-Cocoa==5.3 ; sys_platform == 'darwin'
pyobjc-framework-CoreText==5.3 ; sys_platform == 'darwin'
pyobjc-framework-FSEvents==5.3 ; sys_platform == 'darwin'
pyobjc-framework-Quartz==5.3 ; sys_platform == 'darwin'

# Linux specific packages
#
python-xlib ; sys_platform == 'linux'

# Cross Platform packages
#
six
pillow>=6.2.0
coverage
Expand All @@ -7,4 +26,5 @@ codecov
rst2pdf
Sphinx
mock==2.0.0
codacy-coverage
codacy-coverage

2 changes: 1 addition & 1 deletion docs/index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ There are loads of reasons :-)
Most other tools are not object oriented you end up writing stuff like::

window = findwindow(title = "Untitled - Notepad", class = "Notepad")
SendKeys(window, "%OF") # Format -> Font
send_keys(window, "%OF") # Format -> Font
fontdialog = findwindow("title = "Font")
buttonClick(fontdialog, "OK")

Expand Down
85 changes: 45 additions & 40 deletions pywinauto/application.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,45 @@
# GUI Application automation and testing library
# Copyright (C) 2006-2019 Mark Mc Mahon and Contributors
# https://github.com/pywinauto/pywinauto/graphs/contributors
# http://pywinauto.readthedocs.io/en/latest/credits.html
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of pywinauto nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys

from .base_application import WindowSpecification # noqa: W0611

if sys.platform == 'win32':
from .windows.application import Application # noqa: W0611
else:
from .linux.application import Application # noqa: W0611

__all__ = ["WindowSpecification", "Application"]
# GUI Application automation and testing library
# Copyright (C) 2006-2019 Mark Mc Mahon and Contributors
# https://github.com/pywinauto/pywinauto/graphs/contributors
# http://pywinauto.readthedocs.io/en/latest/credits.html
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of pywinauto nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys

from .base_application import WindowSpecification # noqa: W0611

if sys.platform == 'win32':
from .windows.application import Application # noqa: W0611
elif sys.platform == 'darwin':
from .macos.application import Application
elif sys.platform.startswith('linux'):
from .linux.application import Application # noqa: W0611
else:
raise NotImplementedError('Platform "{}" is not supported! ' \
'Possible platforms: "win32", "linux*", "darwin".'.format(sys.platform))

__all__ = ["WindowSpecification", "Application"]
4 changes: 4 additions & 0 deletions pywinauto/base_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,10 @@ class BaseApplication(object):
.. automethod:: __getitem__
"""

def __iter__(self):
"""Raise to avoid infinite loops"""
raise NotImplementedError("Object is not iterable, try to use method .windows()")

def connect(self, **kwargs):
"""Connect to an already running process

Expand Down
11 changes: 8 additions & 3 deletions pywinauto/controls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
import sys
"""Controls package"""

import sys

if sys.platform.startswith('linux'):
from . import atspiwrapper # register "atspi" back-end
from . import atspi_controls
from .atspiwrapper import InvalidWindowHandle
else:
elif sys.platform == 'win32':
from ..sysinfo import UIA_support
if UIA_support:
from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
Expand All @@ -47,6 +49,9 @@
# contain
from . import common_controls
from . import win32_controls

elif sys.platform == "darwin":
pass
else:
raise NotImplementedError('Platform "{}" is not supported'.format(sys.platform))

from ..base_wrapper import InvalidElement
13 changes: 7 additions & 6 deletions pywinauto/keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,19 @@

from . import deprecated

if sys.platform != 'win32':
from .linux.keyboard import KeySequenceError, KeyAction, PauseAction
from .linux.keyboard import handle_code, parse_keys, send_keys
else:
if sys.platform == 'win32':
import time
import ctypes

import win32api
import six

from .windows import win32structures
from .windows import win32functions
elif sys.platform == "darwin":
from .macos.keyboard import KeySequenceError, KeyAction, PauseAction
from .macos.keyboard import handle_code, parse_keys, send_keys
else:
from .linux.keyboard import KeySequenceError, KeyAction, PauseAction
from .linux.keyboard import handle_code, parse_keys, send_keys

__all__ = ['KeySequenceError', 'send_keys']

Expand Down