├── .gitignore ├── .project ├── .pydevproject ├── LICENSE.TXT ├── README.md ├── docs └── images │ ├── robo_example.png │ └── robo_log_hyperlink.png ├── examples ├── calculator │ ├── __init__.py │ ├── add.py │ ├── add.tsv │ ├── baseline │ │ └── os │ │ │ ├── mac │ │ │ └── Calculator │ │ │ │ ├── Calculator,buttonClear.png │ │ │ │ ├── Calculator,buttonEquals[0].png │ │ │ │ ├── Calculator,buttonEquals[1].png │ │ │ │ ├── Calculator,buttonPlus.png │ │ │ │ ├── Calculator,buttonTwo.png │ │ │ │ ├── Calculator,lcdDisplay-0.png │ │ │ │ ├── Calculator,lcdDisplay-0.py │ │ │ │ ├── Calculator,lcdDisplay-1.png │ │ │ │ ├── Calculator[0].png │ │ │ │ ├── Calculator[0].py │ │ │ │ ├── Calculator[1].png │ │ │ │ └── Calculator[2].png │ │ │ └── windows │ │ │ └── win7 │ │ │ └── Calculator │ │ │ ├── Calculator,buttonClear.png │ │ │ ├── Calculator,buttonEquals.png │ │ │ ├── Calculator,buttonPlus.png │ │ │ ├── Calculator,buttonTwo.png │ │ │ ├── Calculator,lcdDisplay.png │ │ │ └── Calculator.png │ ├── keywords │ │ └── CalculatorLib.py │ ├── maps │ │ ├── __init__.py │ │ └── calculator.py │ └── validate.py └── textedit │ ├── __init__.py │ ├── baseline │ └── os │ │ └── mac │ │ └── TextEdit │ │ ├── TextEdit,bottomRightCorner.png │ │ ├── TextEdit,textArea.png │ │ ├── TextEdit,textArea.py │ │ ├── TextEdit-0.png │ │ ├── TextEdit-0.py │ │ ├── TextEdit-1.png │ │ ├── TextEdit-1.py │ │ ├── TextEdit-2.png │ │ ├── TextEdit.MenuBar,file.png │ │ ├── TextEdit.MenuBar,textEdit.png │ │ ├── TextEdit.MenuBar,textEdit.py │ │ ├── TextEdit.MenuBar.FileMenu.png │ │ ├── TextEdit.MenuBar.TextEditMenu,quit.png │ │ ├── TextEdit.MenuBar.TextEditMenu.png │ │ ├── TextEdit.MenuBar.TextEditMenu.py │ │ ├── TextEdit.MenuBar.png │ │ └── TextEdit.MenuBar.py │ ├── maps │ ├── __init__.py │ └── textedit.py │ └── resize.py ├── java ├── robotframework.jar └── sikuli-script.jar ├── run.py └── src ├── __init__.py ├── bootstrap.py ├── config.py ├── entity ├── __init__.py ├── canvas │ ├── __init__.py │ ├── drawingStrategy.py │ └── turtle.py ├── clickStrategy.py ├── entities │ ├── __init__.py │ ├── application.py │ ├── button.py │ ├── canvas.py │ ├── checkBox.py │ ├── clickableEntity.py │ ├── dropDown.py │ ├── label.py │ ├── progressBar.py │ ├── radio.py │ ├── scrollBar.py │ ├── textBox.py │ └── window.py ├── entity.py ├── exception.py ├── multiResultProxy.py ├── searcher.py └── tests │ ├── __init__.py │ ├── entities.py │ ├── entity.py │ ├── multiResultProxy.py │ └── searcher.py ├── error.py ├── launcher.py ├── log ├── __init__.py ├── entityLoggerProxy.py ├── formatter.py ├── level.py ├── logger.py ├── robotframework │ ├── __init__.py │ ├── formatter.py │ └── handler.py └── tests │ ├── __init__.py │ └── formatter.py ├── region ├── __init__.py ├── exception.py ├── finder.py ├── tests │ ├── __init__.py │ ├── mockFinder.py │ ├── region.py │ └── transform.py └── transform.py ├── robotframework ├── __init__.py ├── common │ ├── RegistryLib.py │ ├── STAXLib.py │ ├── Selenium2Lib.py │ ├── Selenium2Server.py │ ├── ShellLib.py │ ├── ToolsLib.py │ ├── VMWareLib.py │ ├── __init__.py │ └── tests │ │ ├── ShellLib.py │ │ ├── __init__.py │ │ └── tools.py ├── draw_callback_patch.html ├── robotRemoteServer.py └── sikuliFwRfAbstractLib.py ├── tests ├── __init__.py └── mockTool.py ├── tool.py └── wrapper.py /.gitignore: -------------------------------------------------------------------------------- 1 | /results 2 | *$py.class 3 | *.pyc 4 | .settings 5 | java/libs 6 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | sikuli-framework 4 | 5 | 6 | 7 | 8 | 9 | org.python.pydev.PyDevBuilder 10 | 11 | 12 | 13 | 14 | 15 | org.python.pydev.pythonNature 16 | 17 | 18 | -------------------------------------------------------------------------------- /.pydevproject: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | /sikuli-framework/src 7 | /sikuli-framework/java/sikuli-script.jar 8 | /sikuli-framework/examples 9 | 10 | python 2.7 11 | Default 12 | 13 | -------------------------------------------------------------------------------- /LICENSE.TXT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, SMART Technologies ULC 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | * Redistributions of source code must retain the above copyright notice, 8 | this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 13 | the names of its contributors (Joshua Henn) may be used to endorse or 14 | promote products derived from this software without specific prior 15 | written permission. 16 | 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 18 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 23 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 24 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 25 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 26 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SikuliFramework - GUI Automation Framework for Sikuli 2 | ================ 3 | 4 | SikuliFramework provides an object-oriented abstraction on top of [Sikuli](http://www.sikuli.org) to assist with interacting GUI elements, such as sets of buttons, checkboxes, radio buttons, windows and dialogue hierarchies for GUI automation and testing. 5 | 6 | **What is Sikuli?** 7 | 8 | Sikuli is a visual technology to automate and test graphical user interfaces (GUI) using images (screenshots) of the software under test. 9 | - [Wikipedia](http://en.wikipedia.org/wiki/Sikuli) 10 | 11 | ## Common problems with traditional "Sikuli scripts" 12 | 13 | Most traditional "Sikuli scripts" are created by capturing baseline images around a series of steps required to solve a particular problem. This allows for the quick creation of a script to solve a problem. There are however a few inherent problems with creating scripts in this method, these include: 14 | 15 | - Maintainability issues 16 | - Baseline images are usually very specific to a test and cannot be reused 17 | - If the any of the baseline images change, multiple baseline images need be fixed for 1 change in the UI 18 | - No enforced naming convention for baseline pictures (Everyone has a different way of naming things) 19 | - [Fragile tests](http://xunitpatterns.com/Fragile%20Test.html) 20 | - "Sikuli script" often devolve into "hacky" code to get the job done, but it is hard to create truly maintainable tests 21 | - Use of wait(seconds) function depends on computer being fairly fast or increased time is needed, lots of time is wasted waiting around, decreases the readability of tests if there are wait commands everywhere 22 | - Operations are performed without validating whether the system is actually in sync 23 | - Clicking a checkbox, is the checkbox actually selected after the operation? 24 | - Entering text, is the text entered as you expect it? 25 | - Did clicking a button actually perform the action you expected it to? A regular Sikuli script will only fail after it cannot find an image it is expecting to present on the screen 26 | 27 | **SikuliFramework** was created to solve some of the complexities and also offers the following benefits: 28 | 29 | - Cleaner, more readable code 30 | - Provides structure to the naming of baseline images 31 | - Dynamic resolution of image assets (Designate different images based on OS) 32 | - Encourages baseline reuse (Rather than capturing images to solve your immediate task, capture to solve all tasks) 33 | - Higher accuracy matching GUI components due to use of Regions 34 | - Tight integration with [RobotFramework](http://code.google.com/p/robotframework/) - Inspired by [Mike's cognition's Blog](http://blog.mykhailo.com/2011/02/how-to-sikuli-and-robot-framework.html) 35 | - Encourages code reuse in RobotFramework test libraries 36 | - Streamlines baseline creation for assertions (baselines are created automatically during the initial run of the script) 37 | - Solves some of Sikuli's common downfalls (false-positives, context issues) 38 | - Greatly improved reports for debugging and general-purpose 39 | - Increases the robustness of test scripts (less dependant on speed of the machine, resolution, other problems) 40 | 41 | ## Code Examples 42 | 43 | #### Work with applications in a more natural object-oriented way 44 | 45 | calculator = Calculator() 46 | 47 | # Chain together operations on the same window 48 | calculator[Calculator.BUTTON_2].click() 49 | [Calculator.BUTTON_PLUS].click() 50 | [Calculator.BUTTON_2].click() 51 | [Calculator.BUTTON_EQUALS].click() 52 | 53 | # Built-in assertions methods for testing purposes 54 | calculator[Calculator.SCREEN].assertEquals("4") 55 | 56 | #### Integrates with RobotFramework to create extremely readable tests 57 | 58 | *Setting* 59 | Library keywords/CalculatorLib.py WITH NAME Calculator 60 | 61 | *Test Case* 62 | Add Two Numbers 63 | Calculator.Launch 64 | Calculator.Click Two 65 | Calculator.Click Plus 66 | Calculator.Click Two 67 | Calculator.Click Equals 68 | ${Screen}= Calculator.Select Display 69 | Calculator.AssertEquals ${Display} 4 70 | 71 | ![RobotFramework Results Log](https://github.com/smysnk/sikuli-framework/raw/master/docs/images/robo_example.png) 72 | 73 | #### Augments RobotFramework's log.html message statements, adding inline hyperlinking to captured images 74 | 75 | ![RobotFramework Results Log Hyperlinking](https://github.com/smysnk/sikuli-framework/raw/master/docs/images/robo_log_hyperlink.png) 76 | 77 | ### Map out special GUI elements such as a TextBox, Radio, Checkbox + more and interact with them as such 78 | 79 | calculator[Calculator.SCREEN].type("25") 80 | 81 | ### Map out the resulting actions of clicking a button 82 | 83 | # Create initial application context 84 | textedit = TextEdit() 85 | 86 | # Result of clicking the TextEdit button is a TextEditMenu 87 | textEditMenu = textedit[TextEdit.MENU_BAR][MenuBar.TEXTEDIT].click() 88 | 89 | # Perform actions on the new context created from the result of the previous action 90 | textEditMenu[TextEditMenu.QUIT].click() 91 | 92 | ## Getting Started 93 | 94 | [Documentation + Tutorials](https://github.com/smysnk/sikuli-framework/wiki) 95 | 96 | -------------------------------------- 97 | 98 | Created by Joshua Bellamy-Henn 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /docs/images/robo_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/docs/images/robo_example.png -------------------------------------------------------------------------------- /docs/images/robo_log_hyperlink.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/docs/images/robo_log_hyperlink.png -------------------------------------------------------------------------------- /examples/calculator/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /examples/calculator/add.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | """ 32 | Launches Calculator app, adds 2 + 2, verifies the result. 33 | Result log can be found in the /results directory. 34 | """ 35 | 36 | import bootstrap 37 | from config import Config 38 | from log import EntityLoggerProxy 39 | from log.level import TRACE 40 | from maps.calculator import Calculator 41 | from launcher import Launcher 42 | 43 | # Change logging level verbosity 44 | EntityLoggerProxy.getLogger().setLevel(TRACE) 45 | Config.setScreenshotLoggingLevel(TRACE) 46 | 47 | # Launch the Calculator binary 48 | calculator = Launcher.run('Calculator') 49 | 50 | calculator[Calculator.BUTTON_CLEAR].click() \ 51 | [Calculator.BUTTON_2].click() \ 52 | [Calculator.BUTTON_PLUS].click() \ 53 | [Calculator.BUTTON_2].click() \ 54 | [Calculator.BUTTON_EQUALS].click() 55 | 56 | calculator[Calculator.LCD_DISPLAY].assertEquals("4") 57 | 58 | 59 | -------------------------------------------------------------------------------- /examples/calculator/add.tsv: -------------------------------------------------------------------------------- 1 | *Setting* *Value* *Value* *Value* *Value* *Value* *Value* *Value* 2 | Library examples/calculator/keywords/CalculatorLib.py WITH NAME Calculator 3 | 4 | *Test Case* *Action* *Argument* *Argument* *Argument* *Argument* *Argument* *Argument* 5 | Add Two Numbers Pass 6 | Calculator.Launch 7 | Calculator.Click Clear 8 | Calculator.Click Two 9 | Calculator.Click Plus 10 | Calculator.Click Two 11 | Calculator.Click Equals 12 | ${Display}= Calculator.Select Display 13 | Calculator.AssertEquals ${Display} 4 14 | 15 | Add Two Numbers Fail 16 | Calculator.Launch 17 | Calculator.Click Clear 18 | Calculator.Click Two 19 | Calculator.Click Plus 20 | Calculator.Click Two 21 | Calculator.Click Equals 22 | ${Display}= Calculator.Select Display 23 | Calculator.AssertEquals ${Display} 5 -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,buttonClear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,buttonClear.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,buttonEquals[0].png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,buttonEquals[0].png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,buttonEquals[1].png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,buttonEquals[1].png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,buttonPlus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,buttonPlus.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,buttonTwo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,buttonTwo.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,lcdDisplay-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,lcdDisplay-0.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,lcdDisplay-0.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionBelow, RegionMorph,\ 32 | RegionRight 33 | 34 | transforms = { 35 | Transform.CONTEXT_PREVIOUS: [], \ 36 | Transform.CONTEXT_CURRENT: [], \ 37 | Transform.CONTEXT_NEXT: [ 38 | RegionRight(), 39 | ], \ 40 | Transform.CONTEXT_MATCH: [], \ 41 | Transform.CONTEXT_FINAL: [], \ 42 | Transform.CONTEXT_ENTITY: [] 43 | } -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator,lcdDisplay-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator,lcdDisplay-1.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator[0].png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator[0].png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator[0].py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionBelow, RegionMorph 32 | 33 | transforms = { 34 | Transform.CONTEXT_PREVIOUS: [ 35 | RegionMorph(1, 1, 2, 2) 36 | ], \ 37 | Transform.CONTEXT_CURRENT: [], \ 38 | Transform.CONTEXT_NEXT: [ \ 39 | RegionBelow(100), 40 | ], \ 41 | Transform.CONTEXT_MATCH: [], \ 42 | Transform.CONTEXT_FINAL: [], \ 43 | Transform.CONTEXT_ENTITY: [] 44 | } -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator[1].png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator[1].png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/mac/Calculator/Calculator[2].png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/mac/Calculator/Calculator[2].png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonClear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonClear.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonEquals.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonEquals.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonPlus.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonPlus.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonTwo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/windows/win7/Calculator/Calculator,buttonTwo.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/windows/win7/Calculator/Calculator,lcdDisplay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/windows/win7/Calculator/Calculator,lcdDisplay.png -------------------------------------------------------------------------------- /examples/calculator/baseline/os/windows/win7/Calculator/Calculator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/calculator/baseline/os/windows/win7/Calculator/Calculator.png -------------------------------------------------------------------------------- /examples/calculator/keywords/CalculatorLib.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import bootstrap 32 | from launcher import Launcher 33 | import os, sys 34 | from org.sikuli.basics import OS 35 | from robotframework import RobotRemoteServer, SikuliFwRfAbstractLib 36 | from calculator.maps import Calculator 37 | 38 | class CalculatorLib(SikuliFwRfAbstractLib): 39 | 40 | def find(self): 41 | if not self.entity: 42 | self.create() 43 | 44 | self.entity.validate() 45 | 46 | def create(self): 47 | self.entity = Calculator() 48 | 49 | def launch(self): 50 | self.entity = Launcher.run('Calculator') 51 | 52 | 53 | if __name__ == "__main__": 54 | 55 | RobotRemoteServer(CalculatorLib(), *sys.argv[1:]) 56 | 57 | -------------------------------------------------------------------------------- /examples/calculator/maps/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from calculator import * 31 | -------------------------------------------------------------------------------- /examples/calculator/maps/calculator.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity import Window, Button, TextBox, DropDown, Application,\ 32 | CheckBox, Radio, ProgressBar 33 | from org.sikuli.basics import OS 34 | 35 | 36 | class Calculator(Application): 37 | 38 | shared_state = {} 39 | 40 | LCD_DISPLAY = ["lcdDisplay", TextBox] 41 | BUTTON_0 = ["buttonZero", Button] 42 | BUTTON_1 = ["buttonOne", Button] 43 | BUTTON_2 = ["buttonTwo", Button] 44 | BUTTON_3 = ["buttonThree", Button] 45 | BUTTON_4 = ["buttonFour", Button] 46 | BUTTON_5 = ["buttonFive", Button] 47 | BUTTON_6 = ["buttonSix", Button] 48 | BUTTON_7 = ["buttonSeven", Button] 49 | BUTTON_8 = ["buttonEight", Button] 50 | BUTTON_9 = ["buttonNine", Button] 51 | BUTTON_DECIMAL = ["buttonDecimal", Button] 52 | BUTTON_EQUALS = ["buttonEquals", Button] 53 | BUTTON_PLUS = ["buttonPlus", Button] 54 | BUTTON_MINUS = ["buttonMinus", Button] 55 | BUTTON_MULTIPLY = ["buttonMultiply", Button] 56 | BUTTON_NEGATE = ["buttonNegate", Button] 57 | BUTTON_DIVIDE = ["buttonDivide", Button] 58 | BUTTON_CLEAR = ["buttonClear", Button] 59 | BUTTON_MEMORY_CLEAR = ["buttonMemoryClear", Button] 60 | BUTTON_MEMORY_ADD = ["buttonMemoryAdd", Button] 61 | BUTTON_MEMORY_SUBTRACT = ["buttonMemorySubtract", Button] 62 | BUTTON_MEMORY_RECALL = ["buttonMemoryRecall", Button] 63 | 64 | def __init__(self): 65 | super(Calculator, self).__init__() 66 | 67 | self.binary[OS.WINDOWS] = 'calc.exe' 68 | self.binary[OS.MAC] = 'open /Applications/Calculator.app' 69 | -------------------------------------------------------------------------------- /examples/calculator/validate.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | import bootstrap 31 | from config import Config 32 | from log import EntityLoggerProxy 33 | from log.level import TRACE 34 | from maps.calculator import Calculator 35 | from launcher import Launcher 36 | 37 | """ 38 | Simple example that validates that the calculator is present on the screen. 39 | Results can be found in the /results directory. 40 | """ 41 | 42 | # Change logging level verbosity 43 | EntityLoggerProxy.getLogger().setLevel(TRACE) 44 | Config.setScreenshotLoggingLevel(TRACE) 45 | 46 | # Launch the Calculator binary 47 | calculator = Launcher.run('Calculator') 48 | 49 | # Validate that the calculator exists on the screen 50 | calculator.validate() 51 | -------------------------------------------------------------------------------- /examples/textedit/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit,bottomRightCorner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit,bottomRightCorner.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit,textArea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit,textArea.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit,textArea.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionMorph, RegionLimitByParent,\ 32 | PatternSimilarity 33 | 34 | transforms = { 35 | Transform.CONTEXT_PREVIOUS: [], \ 36 | Transform.CONTEXT_CURRENT: [ 37 | PatternSimilarity(0.84), 38 | ], \ 39 | Transform.CONTEXT_NEXT: [], \ 40 | Transform.CONTEXT_MATCH: [], \ 41 | Transform.CONTEXT_FINAL: [ 42 | RegionMorph(0,15,2000,2000), 43 | RegionLimitByParent() 44 | ], \ 45 | Transform.CONTEXT_ENTITY: [] 46 | } -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit-0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit-0.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit-0.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionRight 32 | 33 | transforms = { 34 | Transform.CONTEXT_PREVIOUS: [], \ 35 | Transform.CONTEXT_CURRENT: [], \ 36 | Transform.CONTEXT_NEXT: [ \ 37 | RegionRight(), # The next search region should be to the right of the current match 38 | ], \ 39 | Transform.CONTEXT_MATCH: [], \ 40 | Transform.CONTEXT_FINAL: [], \ 41 | Transform.CONTEXT_ENTITY: [] 42 | } -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit-1.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit-1.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionBelow, ActionClick 32 | 33 | transforms = { 34 | Transform.CONTEXT_PREVIOUS: [ 35 | ActionClick(0,0) # Highlight the window 36 | ], \ 37 | Transform.CONTEXT_CURRENT: [], \ 38 | Transform.CONTEXT_NEXT: [ \ 39 | RegionBelow() # The next search region should be blow the current match 40 | ], \ 41 | Transform.CONTEXT_MATCH: [], \ 42 | Transform.CONTEXT_FINAL: [], \ 43 | Transform.CONTEXT_ENTITY: [] 44 | } -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit-2.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar,file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar,file.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar,textEdit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar,textEdit.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar,textEdit.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionRight, RegionScreen, RegionBelow,\ 32 | ClickableEntityClickStrategy, RegionNearby 33 | from entity.clickStrategy import QuickClick 34 | 35 | transforms = { 36 | Transform.CONTEXT_PREVIOUS: [ 37 | RegionNearby(10) # Give some buffer room 38 | ], \ 39 | Transform.CONTEXT_CURRENT: [], \ 40 | Transform.CONTEXT_NEXT: [], \ 41 | Transform.CONTEXT_MATCH: [], \ 42 | Transform.CONTEXT_FINAL: [], \ 43 | Transform.CONTEXT_ENTITY: [ 44 | ClickableEntityClickStrategy(QuickClick()) 45 | ] 46 | } -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.FileMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.FileMenu.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.TextEditMenu,quit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.TextEditMenu,quit.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.TextEditMenu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.TextEditMenu.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.TextEditMenu.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionRight, RegionScreen, RegionBelow,\ 32 | RegionMorph 33 | 34 | transforms = { 35 | Transform.CONTEXT_PREVIOUS: [ 36 | RegionMorph(0, 0, 100, 200) 37 | ], \ 38 | Transform.CONTEXT_CURRENT: [], \ 39 | Transform.CONTEXT_NEXT: [], \ 40 | Transform.CONTEXT_MATCH: [], \ 41 | Transform.CONTEXT_FINAL: [], \ 42 | Transform.CONTEXT_ENTITY: [] 43 | } -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.png -------------------------------------------------------------------------------- /examples/textedit/baseline/os/mac/TextEdit/TextEdit.MenuBar.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from region.transform import Transform, RegionRight, RegionScreen, RegionBelow,\ 32 | RegionMorph 33 | 34 | transforms = { 35 | Transform.CONTEXT_PREVIOUS: [ 36 | RegionScreen(), # Since the menu bar on OSX is not part of the application it self, don't use the application region context 37 | RegionBelow(25) # Menu bar is at the top of the screen, less than 25 pixels high 38 | ], \ 39 | Transform.CONTEXT_CURRENT: [], \ 40 | Transform.CONTEXT_NEXT: [], \ 41 | Transform.CONTEXT_MATCH: [ 42 | RegionMorph(-500,0,1000,0) # Expand to fit full width 43 | ], \ 44 | Transform.CONTEXT_FINAL: [], \ 45 | Transform.CONTEXT_ENTITY: [] 46 | } -------------------------------------------------------------------------------- /examples/textedit/maps/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | """ 31 | 32 | GUI mapping definitions 33 | 34 | """ 35 | -------------------------------------------------------------------------------- /examples/textedit/maps/textedit.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity import Window, Button, TextBox, DropDown, Application,\ 32 | CheckBox, Radio, ProgressBar 33 | from org.sikuli.script import OS 34 | 35 | class FileMenu(Window): 36 | pass 37 | 38 | class TextEditMenu(Window): 39 | QUIT = ['quit', Button] 40 | 41 | class MenuBar(Window): 42 | statusCascade = True 43 | 44 | FILE = ['file', Button, {'result':FileMenu}] 45 | TEXTEDIT = ['textEdit', Button, {'result':TextEditMenu}] 46 | 47 | class TextEdit(Application): 48 | 49 | shared_state = {} 50 | 51 | MENU_BAR = [MenuBar] 52 | BOTTOM_RIGHT_CORNER = ["bottomRightCorner", Button] 53 | TEXT_AREA = ['textArea', TextBox] 54 | 55 | def __init__(self): 56 | super(TextEdit, self).__init__() 57 | 58 | self.binary[OS.MAC] = 'open /Applications/TextEdit.app' 59 | -------------------------------------------------------------------------------- /examples/textedit/resize.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | import bootstrap 31 | from config import Config 32 | from log import EntityLoggerProxy 33 | from log.level import TRACE 34 | from maps.textedit import TextEdit, MenuBar, FileMenu, TextEditMenu 35 | from region.transform import RegionMorph 36 | from launcher import Launcher 37 | 38 | """ 39 | Simple example that validates that the calculator is present on the screen. 40 | This example does not use the Launcher() class so it assumes that the application 41 | is already running. Results can be found in the /results directory. 42 | """ 43 | 44 | # Change logging level verbosity 45 | #EntityLoggerProxy.getLogger().setLevel(TRACE) 46 | Config.setScreenshotLoggingLevel(TRACE) 47 | 48 | 49 | # Launch the Calculator binary 50 | textedit = Launcher.run('TextEdit') 51 | logger = EntityLoggerProxy(textedit) 52 | 53 | # Type some text in the text area 54 | textedit[TextEdit.TEXT_AREA].type("This is a demo of SikuliFramework") 55 | 56 | # Resize the application size 4 times 57 | for i in range(0,4): 58 | 59 | # Get the current application region 60 | region = textedit.validate().region 61 | 62 | # Alternate between growing / shrinking application width 63 | offset = 100 * (1 - ((i % 2)*2)) 64 | 65 | # Modify the size of current application region 66 | morph = RegionMorph(0, 0, offset, 0) 67 | region = morph.apply(region) 68 | region = region.right(0).below(0) # Get the bottom right corner 69 | 70 | logger.info("resizing bottom right corner to %s" % region) 71 | 72 | # Drag the bottom right hand corner 100px to right 73 | textedit[TextEdit.BOTTOM_RIGHT_CORNER].drag(region) 74 | 75 | # Close down the application 76 | textedit[TextEdit.MENU_BAR][MenuBar.TEXTEDIT].click() \ 77 | [TextEditMenu.QUIT].click() 78 | -------------------------------------------------------------------------------- /java/robotframework.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/java/robotframework.jar -------------------------------------------------------------------------------- /java/sikuli-script.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/java/sikuli-script.jar -------------------------------------------------------------------------------- /src/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from wrapper import * -------------------------------------------------------------------------------- /src/config.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | 32 | from sikuli.Sikuli import setShowActions, getNumberScreens 33 | from org.sikuli.basics import Settings 34 | import os 35 | import java 36 | from java.lang import Thread 37 | from sikuli import Env, Screen 38 | from org.sikuli.script import Region as JRegion 39 | 40 | # http://sikuli.org/docx/globals.html#Settings.MinSimilarity 41 | Settings.MoveMouseDelay = 0 42 | Settings.SlowMotionDelay = 0 43 | Settings.DelayAfterDrag = 0 44 | Settings.DelayBeforeDrop = 0 45 | Settings.MinSimilarity = 0.8 # The default minimum similiarty of find operations. While using a Region.find() operation, if only an image file is provided, Sikuli searches the region using a default minimum similarity of 0.7. 46 | Settings.ObserveScanRate = 0.5 # http://sikuli.org/docx/globals.html#Settings.ObserveScanRate 47 | Settings.WaitScanRate = 1 48 | 49 | class Config(): 50 | 51 | highlightTime = 1 # When debugging is enabled.. highlight exists, wait, etc 52 | waitTime = 0 53 | 54 | imageBaseline = "resources/baseline" # image baseline directory 55 | 56 | loggingLevel = None # If 'development' file exists in root, we're in dev env 57 | screenshotLoggingLevel = None 58 | 59 | debugPlaybackMode = False #debugPlaybackMode = True if os.path.isfile('development') else False 60 | 61 | resultDir = "results/" 62 | resultAssetDir = "assets/" 63 | imageSuffix = ".png" 64 | screen = Screen( 0 ) 65 | 66 | language = "en" 67 | locale = "CA" 68 | captureBaseline = False 69 | 70 | regionTimeout = 3 71 | 72 | # Initialize the logger and set the logging level 73 | logger = None #log.Logger(level=loggingLevel) - move to bootstrap 74 | 75 | #os = Env.getOS() 76 | #osVersion = Env.getOSVersion(fullName=True) 77 | #arch = java.lang.System.getProperty('os.arch') 78 | 79 | mainThread = Thread.currentThread() 80 | 81 | @classmethod 82 | def setRegionTimeout(cls, timeout): 83 | cls.regionTimeout = timeout 84 | JRegion.timeout = Config.regionTimeout 85 | 86 | @classmethod 87 | def setLogger(cls, logger): 88 | cls.logger = logger 89 | 90 | @classmethod 91 | def getLogger(cls): 92 | return cls.logger 93 | 94 | @classmethod 95 | def getLoggingLevel(cls): 96 | return cls.logger.getLoggingLevel() 97 | 98 | @classmethod 99 | def getScreen(cls): 100 | return cls.screen 101 | 102 | @classmethod 103 | def setScreenshotLoggingLevel(cls, level): 104 | 105 | cls.logger.getLogger().log(level, "Changing screenshot logging level") 106 | cls.screenshotLoggingLevel = level 107 | 108 | @classmethod 109 | def getScreenshotLoggingLevel(cls): 110 | return cls.screenshotLoggingLevel 111 | 112 | @classmethod 113 | def toString(cls): 114 | 115 | str = "Highlight time=%d\n" % cls.highlightTime 116 | str = str + "waitTime=%d\n" % cls.waitTime 117 | str = str + "screen=%s (available=%d)\n" % (cls.screen, Screen.getNumberScreens()) 118 | str = str + "regionTimeout=%d\n" % cls.regionTimeout 119 | str = str + "logLevel=%s\n" % cls.loggingLevel 120 | str = str + "screenshotLogLevel=%s\n" % cls.screenshotLoggingLevel 121 | 122 | return str -------------------------------------------------------------------------------- /src/entity/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity import Entity 32 | from entities import * 33 | from multiResultProxy import * 34 | from searcher import * 35 | -------------------------------------------------------------------------------- /src/entity/canvas/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /src/entity/canvas/drawingStrategy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from org.sikuli.script import Location 32 | from sikuli.Region import Region 33 | 34 | class DrawingStrategy(object): 35 | 36 | obj = None 37 | enabled = None 38 | 39 | def __init__(self, obj): 40 | 41 | self.obj = obj 42 | self.state = False 43 | 44 | def goto(self, x, y): 45 | 46 | raise Exception("This method must be subclased") 47 | 48 | def on(self): 49 | self.enabled = True 50 | 51 | def off(self): 52 | self.enabled = False 53 | 54 | 55 | class ContiniousDrawingStrategy(DrawingStrategy): 56 | 57 | queue = None 58 | region = None 59 | 60 | def goto(self, x, y): 61 | 62 | 63 | if self.enabled: 64 | self.queue.append([x, y]) 65 | 66 | if not self.region: 67 | self.region = Region(x, y, 1, 1) 68 | else: 69 | self.region = self.region.add(Location(x, y)) 70 | 71 | 72 | def on(self): 73 | 74 | super(ContiniousDrawingStrategy, self).on() 75 | self.queue = [] 76 | self.region = None 77 | 78 | def off(self): 79 | 80 | super(ContiniousDrawingStrategy, self).off() 81 | 82 | # Prepare to draw annotation 83 | self.obj.center(self.region) 84 | 85 | # Move to first location 86 | self.obj.mouseMove(self.queue[0][0], self.queue[0][1]) 87 | self.obj.startDrawing() 88 | 89 | for location in self.queue[1:]: 90 | self.obj.mouseMove(location[0], location[1]) 91 | 92 | self.obj.stopDrawing() 93 | 94 | 95 | 96 | class SegmentDrawingStrategy(DrawingStrategy): 97 | 98 | x = None 99 | y = None 100 | 101 | def goto(self, x, y): 102 | 103 | 104 | if self.enabled and self.x != None and self.y != None: 105 | 106 | # Make sure the canvas area is setup right 107 | self.obj.center(Location(float(self.x), float(self.y))) 108 | self.obj.center(Location(float(x), float(y))) 109 | 110 | # Draw a line from the last location 111 | self.obj.mouseMove(float(self.x), float(self.y)) 112 | self.obj.startDrawing() 113 | self.obj.mouseMove(float(x), float(y)) 114 | self.obj.stopDrawing() 115 | 116 | 117 | self.x = x 118 | self.y = y 119 | 120 | 121 | class PracticeDrawingStrategy(DrawingStrategy): 122 | 123 | region = None 124 | 125 | def goto(self, x, y): 126 | 127 | if not self.region: 128 | self.region = Region(x, y, 1, 1) 129 | else: 130 | self.region = self.region.add(Location(x,y)) 131 | 132 | def on(self): 133 | 134 | self.region = None 135 | super(PracticeDrawingStrategy, self).on() 136 | 137 | def off(self): 138 | 139 | self.obj.center(self.region) 140 | super(PracticeDrawingStrategy, self).off() 141 | 142 | -------------------------------------------------------------------------------- /src/entity/clickStrategy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from sikuli.Sikuli import sleep 32 | from org.sikuli.script import Pattern 33 | from java.awt.event import InputEvent 34 | 35 | class ClickStrategy(object): 36 | 37 | screen = None 38 | logger = None 39 | 40 | @classmethod 41 | def setScreen(cls, screen): 42 | cls.screen = screen 43 | 44 | @classmethod 45 | def setLogger(cls, logger): 46 | cls.logger = logger 47 | 48 | def __init__(self): 49 | pass 50 | 51 | def click(self, *args, **args): 52 | raise Exception("Must be subclassed") 53 | 54 | class StandardClick(ClickStrategy): 55 | 56 | def __init__(self): 57 | super(StandardClick, self).__init__() 58 | 59 | 60 | def click(self, entity, button=InputEvent.BUTTON1_MASK): 61 | self.screen.mouseMove(entity.getRegion().getClickLocation()) 62 | sleep(0.1) 63 | self.screen.mouseDown(button) 64 | sleep(1) 65 | self.screen.mouseUp(button) 66 | 67 | class QuickClick(ClickStrategy): 68 | """ 69 | Mac requires quick click in order to disply the pop up menus 70 | """ 71 | 72 | def __init__(self): 73 | super(QuickClick, self).__init__() 74 | 75 | 76 | def click(self, entity, button=InputEvent.BUTTON1_MASK): 77 | self.screen.mouseMove(entity.getRegion().getClickLocation()) 78 | sleep(0.1) 79 | self.screen.mouseDown(button) 80 | self.screen.mouseUp(button) 81 | 82 | 83 | class ClickAfterVisualChange(ClickStrategy): 84 | 85 | assertStateChanged = None 86 | 87 | def __init__(self, assertStateChanged=False): 88 | super(ClickAfterVisualChange, self).__init__() 89 | 90 | self.assertStateChanged = assertStateChanged 91 | 92 | def click(self, entity, button=InputEvent.BUTTON1_MASK): 93 | 94 | 95 | # click 96 | self.screen.mouseMove(entity.getRegion().getClickLocation()) 97 | sleep(0.5) 98 | 99 | # Get the state of the button before we click 100 | state = self.screen.capture(entity.getRegion()) 101 | #sleep(0.2) 102 | 103 | self.screen.mouseDown(button) 104 | sleep(0.5) 105 | 106 | # Wait for button to change its appearnce because we're clicking on it 107 | if entity.getRegion().waitVanish(Pattern(state).similar(1.0), 0.7): 108 | sleep(0.2) 109 | else: 110 | if self.assertStateChanged: 111 | raise Exception("State did not change") 112 | else: 113 | self.logger.warn("State did not change") 114 | 115 | self.screen.mouseUp(button) 116 | sleep(0.5) 117 | 118 | -------------------------------------------------------------------------------- /src/entity/entities/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from window import * 31 | from application import * 32 | from clickableEntity import * 33 | from button import * 34 | from label import * 35 | from radio import * 36 | from checkBox import * 37 | from scrollBar import * 38 | from textBox import * 39 | from progressBar import * 40 | from dropDown import * 41 | from canvas import * -------------------------------------------------------------------------------- /src/entity/entities/application.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from entity import Entity 31 | from wrapper import Env 32 | import re 33 | from org.sikuli.basics import OS 34 | 35 | class Application(Entity): 36 | """ Application Entitiy """ 37 | 38 | # For borg/singleton pattern 39 | shared_state = None 40 | 41 | family = True 42 | pid = None 43 | applicationProcess = None 44 | processMonitor = None 45 | 46 | binary = { 47 | OS.WINDOWS : None, #'SMART Technologies/Education Software/Notebook.exe' 48 | OS.MAC : None, #'SMART Technologies/Notebook.app' 49 | OS.LINUX : None #'/opt/SMART Technologies/SMART Notebook/bin/notebook' 50 | } 51 | 52 | workingDir = { 53 | OS.WINDOWS : None, 54 | OS.MAC : None, 55 | OS.LINUX: None, 56 | } 57 | 58 | def __init__(self, *args, **kargs): 59 | self.__dict__ = self.shared_state # borg pattern, singleton 60 | if self.region: return # singleton hackin 61 | 62 | super(Application, self).__init__(None, *args, **kargs) 63 | 64 | def setApplicationProcess(self, process, monitor=True): 65 | self.applicationProcess = process 66 | 67 | match = re.search(r"\(([0-9]*)\)", str(process)) 68 | if match and match.group(1): 69 | self.pid = int(match.group(1)) 70 | else: 71 | raise Exception("Unable to match process id") 72 | 73 | # Add to performance monitor 74 | if monitor: 75 | self.processMonitor.add(self.pid) 76 | 77 | 78 | def getApplicationProcess(self): 79 | return self.applicationProcess 80 | 81 | def getPid(self): 82 | return self.pid 83 | 84 | def getBinary(self, os, osVersion, arch): 85 | return self.parsePath(os, osVersion, arch, self.binary[os]) 86 | 87 | def getWorkingDir(self, os, osVersion, arch): 88 | if self.workingDir[os]: 89 | return self.parsePath(os, osVersion, arch, self.workingDir[os]) 90 | else: 91 | return None 92 | 93 | def parsePath(self, os, osVersion, arch, path): 94 | if path[:1] == '/' or path[:3].lower() == 'c:\\': 95 | pass # absolute path 96 | elif os == OS.WINDOWS and (arch == 'x64' or osVersion == "XP"): 97 | path = path.replace('<%Program Files%>', 'c:/Program Files') 98 | elif os == OS.WINDOWS and arch == 'x86': 99 | path = path.replace('<%Program Files%>', 'c:/Program Files (x86)') 100 | 101 | return path -------------------------------------------------------------------------------- /src/entity/entities/button.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from entity.entities import ClickableEntity 31 | 32 | class Button(ClickableEntity): 33 | """ Button Entity """ 34 | 35 | def __init__(self, parent, *args, **kargs): 36 | super(Button, self).__init__(parent, *args, **kargs) -------------------------------------------------------------------------------- /src/entity/entities/checkBox.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity.entities import ClickableEntity 32 | 33 | class CheckBox(ClickableEntity): 34 | """ CheckBox Entity """ 35 | 36 | def __init__(self, parent, *args, **kargs): 37 | super(CheckBox, self).__init__(parent, *args, **kargs) 38 | -------------------------------------------------------------------------------- /src/entity/entities/clickableEntity.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity import Entity 32 | from java.awt.event import InputEvent 33 | from region.exception import FindExhaustedException 34 | from entity.exception import StateFailedException 35 | from sikuli.Sikuli import sleep 36 | 37 | class ClickableEntity(Entity): 38 | 39 | postState = None 40 | statusCascade = True 41 | 42 | clickStrategy = None #StandardClick() - Use dep injection now 43 | #clickStrategy = ClickAfterVisualChange() 44 | 45 | # Image State 46 | STATE_NONE = "" 47 | STATE_DISABLED = "disabled" 48 | STATE_DISABLED_SELECTED = "disabled-selected" 49 | STATE_SELECTED = "selected" 50 | STATE_UNSELECTED = "unselected" 51 | 52 | LEFT_MOUSE = InputEvent.BUTTON1_MASK 53 | RIGHT_MOUSE = InputEvent.BUTTON3_MASK 54 | 55 | @classmethod 56 | def setDefaultClickStrategy(cls, clickStrategy): 57 | cls.clickStrategy = clickStrategy 58 | 59 | def __init__(self, parent, invalidate=False, clickStrategy=None, *args, **kargs): 60 | super(ClickableEntity, self).__init__(parent, *args, **kargs) 61 | 62 | self.clickInvalidate = invalidate 63 | 64 | if clickStrategy: 65 | self.clickStrategy = clickStrategy 66 | 67 | 68 | def drag(self, destination): 69 | 70 | # Ensure valid 71 | self.validate() 72 | 73 | # Move the mouse to this entity 74 | self.config.screen.mouseMove(self.region) 75 | sleep(0.1) 76 | self.config.screen.mouseDown(InputEvent.BUTTON1_MASK) 77 | sleep(0.4) 78 | self.config.screen.mouseMove(destination) 79 | sleep(0.3) 80 | self.config.screen.mouseUp(InputEvent.BUTTON1_MASK) 81 | 82 | # This entity is no longer valid since it's been dragged 83 | self.invalidate() 84 | 85 | 86 | def click(self, callback=None, callbackContext=None, resultArgs=None, postState=None, verifyClick=True, resultParent=None, button=LEFT_MOUSE, **kargs): 87 | """ Select a element (eg. Button) """ 88 | 89 | # Ensure valid 90 | self.validate() 91 | 92 | # Uses composition so that click behavior can be changed on a per-entity basis 93 | self.clickStrategy.click(self) 94 | self.logger.info("clicked") 95 | 96 | # Assert the state of the button after clicking it 97 | self.assertState(postState) 98 | 99 | # invalidate 100 | if self.clickInvalidate: 101 | self.invalidate(self) 102 | 103 | # override callback with callback from this function 104 | callback = callback if callback else self.callback 105 | callbackContext = callbackContext if callbackContext else self.callbackContext 106 | 107 | # perform callback 108 | if callback and callbackContext: 109 | callback(callbackContext) 110 | elif callback: 111 | callback(self) 112 | 113 | # Update context with update pairs --- What for?! What does this do? 114 | if callbackContext and self.updatePairs: 115 | for pair in self.updatePairs: 116 | callbackContext.__dict__[pair[0]] = pair[1] 117 | 118 | # Use result args are supplied use them, else use the ones supplied when the object was created 119 | resultArgs = resultArgs if resultArgs else self.resultArgs 120 | 121 | return self.getResult(resultParent=resultParent, **resultArgs) 122 | 123 | 124 | def assertState(self, state=None): 125 | 126 | # Ensure valid 127 | self.validate() 128 | 129 | # if not specified in method, default to constructor value 130 | if not state and self.postState: 131 | state = self.postState 132 | 133 | # Check if there is a post state of clicking this button 134 | if state: 135 | self.logger.trace("trying to verify state=%s" % state) 136 | 137 | # try and click the button 138 | # TODO: (tt::) next line is broken because regionFinder is probably not a static function, can't call it like this 139 | ir = Entity.regionFinder(self, region=self.region, state=state) # image region of the button 140 | try: 141 | region = ir.find() 142 | 143 | except FindExhaustedException, e: 144 | raise StateFailedException("incorrect state [%s]" % state) 145 | 146 | self.logger.info('verified state state=%s %%s' % state, self.logger.getFormatter()(ir).showBaselines()) 147 | #self.logger.info('verified state state=%s %%s %%s' % state, Formatter("Match").addImages(region, "actual"), Tag(ir.getImageNames(state=state),"baseline")) 148 | #self.logger.info('verified state [["' + state + '"](' + self.logger.region(region=region) + ':actual,' + ','.join(self.logger.image(ir.getImageNames(state=state), tag="baseline")) + ')]') 149 | 150 | return self.parent 151 | 152 | def setClickStrategy(self, clickStrategy): 153 | self.clickStrategy = clickStrategy -------------------------------------------------------------------------------- /src/entity/entities/dropDown.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from entity.entities import ClickableEntity 31 | 32 | class DropDown(ClickableEntity): 33 | """ DropDown Entity """ 34 | 35 | def __init__(self, parent, *args, **kargs): 36 | super(DropDown, self).__init__(parent, *args, **kargs) 37 | 38 | -------------------------------------------------------------------------------- /src/entity/entities/label.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from entity import Entity 31 | 32 | class Label(Entity): 33 | 34 | statusCascade = True 35 | filter = None 36 | 37 | def addFilter(self, filter): 38 | self.filter = filter 39 | 40 | def getText(self): 41 | 42 | self.validate() 43 | 44 | text = self.region.text() 45 | self.logger.trace("text=%s" % text) 46 | 47 | return text 48 | 49 | def getValue(self): 50 | 51 | value = self.getText() 52 | 53 | if self.filter: 54 | value = self.filter(value).getValue() 55 | 56 | self.logger.trace("postFilter=%s" % value) 57 | 58 | return value -------------------------------------------------------------------------------- /src/entity/entities/progressBar.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from org.sikuli.basics import OS 32 | from org.sikuli.script import KeyModifier, Key, Location 33 | import re 34 | 35 | from region.exception import FindExhaustedException 36 | from entity.exception import StateFailedException 37 | from sikuli.Sikuli import sleep 38 | from sikuli.Region import Region 39 | import time 40 | from entity import Entity 41 | 42 | class ProgressBar(Entity): 43 | """ Button Entity """ 44 | 45 | lastChange = None 46 | 47 | def __init__(self, parent, *args, **kargs): 48 | super(ProgressBar, self).__init__(parent, *args, **kargs) 49 | 50 | def waitUntilComplete(self, timeout=60, resultArgs={}): 51 | 52 | self.validate() 53 | 54 | # Convert Match to Region -> workaround: https://bugs.launchpad.net/sikuli/+bug/905435 55 | r = Region(self.region) 56 | r.onChange(self.__changed) 57 | r.observe(FOREVER, background=True) # start observing progress bar 58 | 59 | startTime = time.time() 60 | self.lastChange = time.time() 61 | # loop while things are still changing 62 | while (time.time()-self.lastChange) < timeout: 63 | sleep(1) 64 | 65 | r.stopObserver() # stop observing progress bar 66 | self.logger.trace("stopped changing after %ds" % (time.time()-startTime)) 67 | 68 | # try and click the button 69 | state = "complete" 70 | ir = self.regionFinder(self, region=self.region, state=state) # image region of the button 71 | try: 72 | region = ir.find() 73 | except FindExhaustedException, e: 74 | raise StateFailedException("incorrect state [%s]" % state) 75 | else: 76 | self.logger.info("completed successfully!") 77 | 78 | return self.getResult(**resultArgs) 79 | 80 | def __changed(self, event): 81 | 82 | # Progress bar has changed 83 | self.lastChange = time.time() 84 | -------------------------------------------------------------------------------- /src/entity/entities/radio.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from entity.entities import ClickableEntity 31 | 32 | class Radio(ClickableEntity): 33 | """ Radio Entity """ 34 | 35 | def __init__(self, parent, *args, **kargs): 36 | super(Radio, self).__init__(parent, *args, **kargs) 37 | -------------------------------------------------------------------------------- /src/entity/entities/scrollBar.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity.entities import Button, Window 32 | from entity import Entity 33 | 34 | def invalidateDragBar(self, context): 35 | context[context.DRAG_BAR].invalidate() 36 | 37 | class ScrollBar(Entity): 38 | 39 | 40 | family = True 41 | UP = ['up', lambda parent, **kargs: Button(parent, context=parent, callback=invalidateDragBar, **kargs)] 42 | DOWN = ['down', lambda parent, **kargs: Button(parent, context=parent, callback=invalidateDragBar, **kargs)] 43 | 44 | DRAG_BAR = ['dragBar', lambda parent, **kargs: Window(parent, **kargs)] 45 | 46 | 47 | def gotoTop(self): 48 | self[self.DRAG_BAR].move(self[self.UP].getRegion()) 49 | return self 50 | 51 | def gotoBottom(self): 52 | self[self.DRAG_BAR].move(self[self.DOWN].getRegion()) 53 | return self 54 | -------------------------------------------------------------------------------- /src/entity/entities/textBox.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity.entity import Entity 32 | from org.sikuli.script import KeyModifier, Key 33 | import re 34 | from java.awt.event import InputEvent 35 | from sikuli.Sikuli import sleep 36 | from wrapper import Env 37 | from sikuli.Region import Region 38 | import string 39 | from org.sikuli.basics import OS 40 | 41 | class TextBox(Entity): 42 | """ Textbox Entity """ 43 | 44 | statusCascade = True 45 | 46 | def __init__(self, parent, *args, **kargs): 47 | super(TextBox, self).__init__(parent, *args, **kargs) 48 | 49 | def assertEquals(self, expectedText): 50 | 51 | # If we're on MAC, use CMD instead of CTRL 52 | if Env.getOS() == OS.MAC: 53 | keyMod = KeyModifier.CMD 54 | else: 55 | keyMod = KeyModifier.CTRL 56 | 57 | # Select 58 | self.config.screen.type(None, "a", keyMod) 59 | sleep(0.5) 60 | 61 | self.config.screen.type(None, "c", keyMod) 62 | sleep(0.5) 63 | 64 | clipboardContents = Env.getClipboard() 65 | if clipboardContents != expectedText: 66 | self.logger.error("Clipboard contents [%s] does not match expected value of [%s]" % (clipboardContents, expectedText)) 67 | raise Exception() 68 | else: 69 | self.logger.trace("Verified clipboard contents [%s] equals [%s]" % (clipboardContents, expectedText)) 70 | 71 | def type(self, text, callback=None, context=None, verify=True, **kargs): 72 | """ Select a element (eg. Button) """ 73 | 74 | # Ensure valid 75 | self.validate() 76 | 77 | # Sometimes click isn't registered, implement our own version of click 78 | self.config.screen.mouseMove(self.region.getClickLocation()) 79 | sleep(0.5) 80 | self.config.screen.mouseDown(InputEvent.BUTTON1_MASK) 81 | sleep(0.8) 82 | self.config.screen.mouseUp(InputEvent.BUTTON1_MASK) 83 | sleep(0.5) 84 | 85 | # If we're on OSX, use CMD instead of CTRL 86 | if Env.getOS() == OS.MAC: 87 | keyMod = KeyModifier.CMD 88 | else: 89 | keyMod = KeyModifier.CTRL 90 | 91 | # Select 92 | self.config.screen.type(None, "a", keyMod) 93 | sleep(0.5) 94 | self.config.screen.type(Key.BACKSPACE) 95 | sleep(0.5) 96 | 97 | """ 98 | Note: Config.screen.type() or paste() behaves differently in Windows and Mac regarding clipboard 99 | 100 | In Mac: 101 | Through testing, found that Config.screen.type(text), then copy the text somehow does not store the text in the clipboard. 102 | if we want to retrieve the text properly in Mac from clipboard later, then we have to use "Config.screen.paste(text). 103 | 104 | However, if we use paste() here, then Mac response "prompt adding title page" does not recognize that text has been pasted in the edit 105 | box and the "Add" button will not enabled. (In Mac, you need to actually type something in that edit box for the "Add" button 106 | to be enabled. A bug is raised. 107 | 108 | In Windows: 109 | Both Config.screen.type()/Config.screen.paste() and copy the text STORE the text in the clipboard properly. And Response "prompt adding 110 | title page" recognize the pasted text in the edit box and the "Add" button is enabled properly 111 | """ 112 | self.config.screen.paste(text) 113 | sleep(1.0) 114 | 115 | if verify: 116 | self.config.screen.type(None, "a", keyMod) 117 | sleep(1.0) 118 | self.config.screen.type(None, "c", keyMod) 119 | sleep(1.0) 120 | clipboardContents = Env.getClipboard() 121 | clipboardContents = string.replace(clipboardContents,'\r','') 122 | clipboardContents = string.replace(clipboardContents,'\n','') 123 | 124 | if clipboardContents != text: 125 | self.logger.error("Clipboard contents [%s] does not match expected value of [%s]" % (clipboardContents, text)) 126 | raise Exception() 127 | else: 128 | self.logger.trace("Verified clipboard contents [%s] equals [%s]" % (clipboardContents, text)) 129 | 130 | 131 | self.logger.info('typed ["%s"], on %%s' % (text), self.logger.getFormatter()(self.parent)) 132 | 133 | return self.parent 134 | 135 | -------------------------------------------------------------------------------- /src/entity/entities/window.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from entity import Entity 31 | 32 | class Window(Entity): 33 | """ Window Entitiy """ 34 | 35 | def __init__(self, *args, **kargs): 36 | super(Window, self).__init__(*args, **kargs) 37 | -------------------------------------------------------------------------------- /src/entity/exception.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from error import SikuliFrameworkException 32 | 33 | class UpdateFailureException(SikuliFrameworkException): 34 | pass 35 | 36 | class OCRSearchFailedException(SikuliFrameworkException): 37 | pass 38 | 39 | class StateFailedException(SikuliFrameworkException): 40 | pass 41 | 42 | class SelectFailedException(SikuliFrameworkException): 43 | pass 44 | 45 | class TookTooLongToVanishException(SikuliFrameworkException): 46 | pass 47 | 48 | class TookTooLongToAppearException(SikuliFrameworkException): 49 | pass -------------------------------------------------------------------------------- /src/entity/multiResultProxy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import inspect 32 | 33 | class MultiResultProxy(object): 34 | """ 35 | When the result of clicking an entity has more than one outcomes this proxy class is used to support all of them. 36 | It helps us lazy load the desired outcome specified by the client. 37 | """ 38 | 39 | parent = None 40 | results = None 41 | resultArgs = {} 42 | caller = None 43 | entitySeacher = None 44 | 45 | @classmethod 46 | def setEntitySearcher(cls, entitySearcher): 47 | cls.entitySeacher = entitySearcher 48 | 49 | def __init__(self, parent, results, caller): 50 | 51 | self.parent = parent 52 | 53 | assert isinstance(results, list) 54 | self.setResults(results) 55 | self.caller = caller 56 | 57 | self.searcher = self.entitySeacher() 58 | self.searcher.add(self) 59 | 60 | 61 | def __getitem__(self, key): 62 | """ 63 | Initiate class based on which key is supplied 64 | Eg. key = WindowEntity.KEY 65 | 66 | 2) Initiate the Window 67 | 68 | """ 69 | 70 | searchResult = self.searcher.search(key) 71 | 72 | if inspect.isfunction(searchResult.getParent()): 73 | parent = searchResult.getParent()(self.parent) 74 | elif searchResult.getParent(): 75 | parent = searchResult.getParent() 76 | else: 77 | parent = self.parent 78 | 79 | try: 80 | # Try the key as a member variable 81 | 82 | owner = searchResult.getOwner()(parent, caller=self, **self.resultArgs) 83 | return owner[searchResult.getEntity()] 84 | 85 | except TypeError: 86 | # Key was a class 87 | 88 | return searchResult.getEntity()[0](parent, caller=self, **self.resultArgs) 89 | 90 | finally: 91 | pass 92 | 93 | def setResults(self, results): 94 | 95 | self.results = [] 96 | 97 | # Allow for lambda parents, we need to evaluate them before they can be searched 98 | for result in results: 99 | # Evaluate lambda's 100 | if isinstance(result, tuple) and inspect.isfunction(result[0]): 101 | result = (result[0](),result[1]) 102 | 103 | self.results.append(result) 104 | 105 | 106 | def getResults(self): 107 | return self.results 108 | 109 | def setResultArgs(self, args): 110 | 111 | self.resultArgs = args 112 | 113 | -------------------------------------------------------------------------------- /src/entity/tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /src/entity/tests/entities.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import unittest 32 | from entity import Entity, Window, Button, Application 33 | from region.tests.mockFinder import Finder 34 | from entity.searcher import Searcher 35 | from log import Logger 36 | 37 | class SecondDescendant(Window): 38 | 39 | shared_state = {} 40 | 41 | CHILD = ["Child", lambda parent, **kargs: Button(parent, **kargs)] 42 | 43 | class SecondFamily(Window): 44 | 45 | shared_state = {} 46 | family = True 47 | 48 | SECOND_DESCENDANT = [SecondDescendant, lambda parent, **kargs: SecondDescendant(parent, **kargs)] 49 | 50 | class FirstDescendant(Window): 51 | 52 | SECOND_FAMILY = [SecondFamily, lambda parent, **kargs: SecondFamily(parent, **kargs)] 53 | 54 | class FirstFamily(Window): 55 | 56 | family = True 57 | shared_state = {} 58 | 59 | FIRST_DESCENDANT = [FirstDescendant, lambda parent, **kargs: FirstDescendant(parent, **kargs)] 60 | 61 | class SecondNode(Window): 62 | 63 | shared_state = {} 64 | 65 | FIRST_FAMILY = [FirstFamily, lambda parent, **kargs: FirstFamily(parent, **kargs)] 66 | 67 | class Root(Application): 68 | 69 | shared_state = {} 70 | 71 | SECOND_NODE = [SecondNode, lambda parent, **kargs: SecondNode(parent, **kargs)] 72 | 73 | 74 | class NameTests(unittest.TestCase): 75 | 76 | entity = None 77 | 78 | def setUp(self): 79 | Entity.setRegionFinderStrategy(Finder) 80 | Entity.setSearcherStrategy(Searcher) 81 | Entity.setLogger(Logger) 82 | 83 | 84 | def tearDown(self): 85 | pass 86 | 87 | 88 | def testConanicalName(self): 89 | 90 | entity = Root()[Root.SECOND_NODE][SecondNode.FIRST_FAMILY][FirstFamily.FIRST_DESCENDANT][FirstDescendant.SECOND_FAMILY][SecondFamily.SECOND_DESCENDANT][SecondDescendant.CHILD] 91 | 92 | # Default args 93 | self.assertEqual(entity.getCanonicalName(),"Root.SecondNode.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant,child") 94 | 95 | # Ancestor complete set (true/false) 96 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=True, topLevel=True),"Root.SecondNode.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant,child") 97 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=True, topLevel=False),"Root.SecondNode.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant") 98 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=False, topLevel=True),"Root,child") 99 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=False, topLevel=False),"Root") 100 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=True, topLevel=True),".SecondNode.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant,child") 101 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=True, topLevel=False),".SecondNode.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant") 102 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=False, topLevel=True),",child") 103 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=False, topLevel=False),"") 104 | 105 | # Ancestor depth=2 106 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=2, topLevel=True),"Root.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant,child") 107 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=2, topLevel=False),"Root.FirstFamily.FirstDescendant.SecondFamily.SecondDescendant") 108 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=2, topLevel=True),".FirstFamily.FirstDescendant.SecondFamily.SecondDescendant,child") 109 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=2, topLevel=False),".FirstFamily.FirstDescendant.SecondFamily.SecondDescendant") 110 | 111 | # Ancestor depth=1 112 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=1, topLevel=True),"Root.SecondFamily.SecondDescendant,child") 113 | self.assertEqual(entity.getCanonicalName(rootEntity=True, ancestorEntities=1, topLevel=False),"Root.SecondFamily.SecondDescendant") 114 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=1, topLevel=True),".SecondFamily.SecondDescendant,child") 115 | self.assertEqual(entity.getCanonicalName(rootEntity=False, ancestorEntities=1, topLevel=False),".SecondFamily.SecondDescendant") 116 | 117 | 118 | def testName(self): 119 | 120 | root = Root() 121 | 122 | self.assertEqual(root.getName(), "Root") 123 | 124 | secondNode = root[Root.SECOND_NODE] 125 | self.assertEqual(secondNode.getName(), "SecondNode") 126 | 127 | firstFamily = secondNode[SecondNode.FIRST_FAMILY] 128 | self.assertEqual(firstFamily.getName(), "FirstFamily") 129 | 130 | 131 | if __name__ == "__main__": 132 | unittest.main() 133 | -------------------------------------------------------------------------------- /src/entity/tests/multiResultProxy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import unittest 32 | from entity import Entity 33 | from entity import Button 34 | from entity.multiResultProxy import MultiResultProxy 35 | 36 | import tests 37 | 38 | 39 | class MultiResultProxyTest(unittest.TestCase): 40 | 41 | 42 | def setUp(self): 43 | pass 44 | 45 | def tearDown(self): 46 | pass 47 | 48 | 49 | def testResultParent(self): 50 | 51 | class GreenMarble(Entity): 52 | GREEN_SPECK = ['greenSpeck', Button] 53 | 54 | class RedMarble(Entity): 55 | RED_SPECK = ['redSpeck', Button] 56 | 57 | class BlueMarble(Entity): 58 | BLUE_SPECK = ['blueSpeck', Button] 59 | 60 | proxy = MultiResultProxy(None, [(RedMarble, BlueMarble(None)),(GreenMarble, BlueMarble(None))], None) 61 | 62 | result = proxy[RedMarble.RED_SPECK] 63 | self.assertEqual(result.getName(), 'redSpeck') 64 | self.assertEqual(result.getParent().getParent().getName(), 'BlueMarble') 65 | 66 | result = proxy[GreenMarble.GREEN_SPECK] 67 | self.assertEqual(result.getName(), 'greenSpeck') 68 | self.assertEqual(result.getParent().getParent().getName(), 'BlueMarble') 69 | 70 | #proxy.find 71 | 72 | 73 | 74 | def testFindClassFromKey(self): 75 | 76 | class RedMarble(Entity): 77 | RED_SPECK = ['redSpeck', Button] 78 | 79 | class BlueMarble(Entity): 80 | BLUE_SPECK = ['blueSpeck', Button] 81 | 82 | proxy = MultiResultProxy(None, [RedMarble, BlueMarble], None) 83 | 84 | # Supplying the RED_SPECK keyword will return the RedMarble class that it belongs to 85 | result = proxy[RedMarble.RED_SPECK] 86 | self.assertEqual(result.getName(), 'redSpeck') 87 | 88 | # Suppling the BLUE_SPEC keyword will return the BlueMarble class that it belongs to 89 | result = proxy[BlueMarble.BLUE_SPECK] 90 | self.assertEqual(result.getName(), 'blueSpeck') 91 | 92 | def testFindClassFromAmbiguousKeyReturnsError(self): 93 | 94 | class RedMarble(Entity): 95 | SPECK = ['speck', Button] 96 | 97 | class BlueMarble(Entity): 98 | SPECK = ['speck', Button] 99 | 100 | 101 | proxy = MultiResultProxy(None, [RedMarble, BlueMarble], None) 102 | 103 | # Make sure finding a class from ambiguous key raises exception 104 | self.assertRaises(Exception, proxy.__getitem__, RedMarble.SPECK) 105 | self.assertRaises(Exception, proxy.__getitem__, BlueMarble.SPECK) 106 | 107 | def testPassingNullKeyRaisesException(self): 108 | 109 | class RedMarble(Entity): 110 | SPECK = ['speck', Button] 111 | 112 | class BlueMarble(Entity): 113 | SPECK = ['speck', Button] 114 | 115 | proxy = MultiResultProxy(None, [RedMarble, BlueMarble], None) 116 | 117 | # Passing an None key will return raise an EntityNotFound exception 118 | self.assertRaises(Exception, proxy.__getitem__, None) 119 | 120 | 121 | def testPassingProxyInvalidKeyRaisesException(self): 122 | 123 | class RedMarble(Entity): 124 | SPECK = ['speck', Button] 125 | 126 | class BlueMarble(Entity): 127 | SPECK = ['speck', Button] 128 | 129 | proxy = MultiResultProxy(None, [RedMarble, BlueMarble], None) 130 | 131 | # Passing an invalid key will return raise an EntityNotFound exception 132 | self.assertRaises(Exception, proxy.__getitem__, ['failEntity',Button]) 133 | 134 | 135 | if __name__ == "__main__": 136 | unittest.main() 137 | -------------------------------------------------------------------------------- /src/error.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | class SikuliFrameworkException(Exception): 32 | 33 | logger = None 34 | screenshot = None 35 | entity = None 36 | config = None 37 | 38 | @classmethod 39 | def setLogger(cls, logger): 40 | cls.logger = logger 41 | 42 | @classmethod 43 | def setConfig(cls, config): 44 | cls.config = config 45 | 46 | def __init__(self, value="", screenshot=False, entity=None, **kargs): 47 | 48 | self.value = value 49 | self.screenshot = screenshot 50 | self.entity = entity 51 | self.logger = self.__class__.logger(entity) 52 | 53 | def __str__(self): 54 | 55 | return "%s %s" % (self.logger.getFormatter()(self.config.screen), self.value) 56 | 57 | class CreateWindowFailed(SikuliFrameworkException): 58 | def __init__(self, value, **kargs): 59 | super(CreateWindowFailed, self).__init__(value, **kargs) 60 | 61 | class ButtonDisabled(SikuliFrameworkException): 62 | def __init__(self, value, **kargs): 63 | super(ButtonDisabled, self).__init__(value, **kargs) -------------------------------------------------------------------------------- /src/launcher.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from entity import Application 32 | from org.sikuli.script import App, Env 33 | from config import Config 34 | from sikuli.Sikuli import sleep 35 | import os as osLib 36 | import java 37 | import subprocess 38 | from wrapper import * 39 | 40 | class Launcher(object): 41 | 42 | logger = None 43 | 44 | @classmethod 45 | def setLogger(cls, logger): 46 | cls.logger = logger(cls) 47 | 48 | @classmethod 49 | def run(cls, className): 50 | """ Launch an application through reflection """ 51 | 52 | cls.logger.info("is attempting to run [%s] wd=%s" % (className, osLib.getcwd())) 53 | 54 | for appCls in Application.__subclasses__(): 55 | if className == appCls.__name__: 56 | 57 | os = Env.getOS() 58 | osVersion = Env.getOSVersion(fullName=True) 59 | arch = java.lang.System.getProperty('os.arch') 60 | 61 | app = appCls() # get an instance of this class 62 | binary = app.getBinary(os, osVersion, arch) # get the binary to run from the instance 63 | cls.logger.info('created [%s] from [%s] [%s %s %s]' % (className, binary, os, osVersion, arch)) 64 | 65 | result = subprocess.Popen(binary, shell=True, cwd=app.getWorkingDir(os, osVersion, arch)) 66 | 67 | return app 68 | 69 | raise Exception("Unable to find Application sub-class [%s], ensure that it is included" % className) 70 | 71 | 72 | @classmethod 73 | def formatPrefix(cls, *args, **args): 74 | return "[Launcher] " 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/log/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | """ 31 | This logger 32 | """ 33 | from entityLoggerProxy import * 34 | from logger import * 35 | from level import * -------------------------------------------------------------------------------- /src/log/entityLoggerProxy.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | import string 31 | from level import * 32 | 33 | class EntityLoggerProxy(object): 34 | """ 35 | Originally there was a singleton logger, but to support a prefix for 36 | which entity the log statement belonged to, this proxy class was created. 37 | """ 38 | 39 | entity = None 40 | logger = None 41 | formatter = None 42 | 43 | @classmethod 44 | def setLogger(cls, logger): 45 | cls.logger = logger 46 | 47 | @classmethod 48 | def getLogger(cls): 49 | return cls.logger 50 | 51 | @classmethod 52 | def setFormatter(cls, formatter): 53 | cls.formatter = formatter 54 | 55 | @classmethod 56 | def getLevel(cls): 57 | return cls.logger.getEffectiveLevel() 58 | 59 | @classmethod 60 | def setLevel(self, level): 61 | self.logger.setLevel(level) 62 | self.logger.log(level, None, "Changing logging level") 63 | 64 | def __init__(self, entity=None, level=None): 65 | 66 | self.entity = entity # associate an entity with this logger 67 | 68 | if level: 69 | self.setLevel(level) 70 | 71 | def setEntity(self, entity): 72 | self.entity = entity 73 | 74 | def log(self, level, msg, *args, **kwargs): 75 | 76 | # Set formatter to the logging level of this log statement 77 | for arg in args: 78 | arg.setLogLevel(level) 79 | 80 | # Remove extra % 81 | if len(args) > 0: # if there are no args supplied for str replacement, don't even try 82 | msg = string.replace(msg, r'%%s',r'%s') 83 | msg = msg % args 84 | 85 | # Formulate the prefix for this log statement 86 | prefix = "%s " % str(self.formatter(self.entity).setLogLevel(level)) if self.entity else '' 87 | 88 | self.logger.log(level, prefix + msg, *args, **kwargs) 89 | 90 | def info(self, msg, *args, **kwargs): 91 | """ Override to support keywords """ 92 | self.log(INFO, msg, *args, **kwargs) 93 | 94 | def warn(self, msg, *args, **kwargs): 95 | """ Override to support keywords """ 96 | self.log(WARN, msg, *args, **kwargs) 97 | 98 | def debug(self, msg, *args, **kwargs): 99 | """ Override to support keywords """ 100 | self.log(DEBUG, msg, *args, **kwargs) 101 | 102 | def trace(self, msg, *args, **kwargs): 103 | self.log(TRACE, msg, *args, **kwargs) 104 | 105 | def error(self, msg, *args, **kwargs): 106 | """ Override to support keywords """ 107 | self.log(ERROR, msg, *args, **kwargs) 108 | 109 | def getFormatter(self): 110 | return self.formatter 111 | 112 | -------------------------------------------------------------------------------- /src/log/level.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import logging 32 | 33 | # Define our own logging levels 34 | ERROR = logging.ERROR 35 | WARN = logging.WARNING 36 | INFO = logging.INFO 37 | DEBUG = logging.DEBUG + 1 38 | TRACE = logging.DEBUG 39 | 40 | 41 | # hack to properly handle WARNING log level 42 | logging.addLevelName(logging.WARNING, 'WARN') # Robot framework likes it like this 43 | logging.addLevelName(logging.ERROR, 'FAIL') # Robot framework likes it like this 44 | 45 | # There is a problem with 46 | logging.addLevelName(logging.DEBUG, 'TRACE') 47 | logging.addLevelName(logging.DEBUG + 1, 'DEBUG') 48 | -------------------------------------------------------------------------------- /src/log/logger.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import logging 32 | import string 33 | from log.robotframework import Handler, Formatter 34 | 35 | class Logger(logging.Logger): 36 | """ 37 | Main logger class 38 | """ 39 | 40 | formatter = None 41 | 42 | def __init__(self): 43 | logging.Logger.__init__(self, "Logger") 44 | 45 | # RobotFramework log handler 46 | fh = Handler() 47 | fh.setFormatter(Formatter()) 48 | self.addHandler(fh) 49 | 50 | # Textfile log handler 51 | fh = logging.FileHandler('results/log.txt', mode='w') 52 | fh.setFormatter(Formatter()) 53 | self.addHandler(fh) 54 | 55 | def log(self, level, msg, *args, **kwargs): 56 | logging.Logger.log(self, level, msg) 57 | 58 | -------------------------------------------------------------------------------- /src/log/robotframework/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from formatter import * 32 | from handler import * -------------------------------------------------------------------------------- /src/log/robotframework/formatter.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import string 32 | import time 33 | import logging 34 | 35 | class Formatter(logging.Formatter): 36 | """ 37 | This custom formatter is necessary to create log entries in a way that RobotFramework expects. 38 | The main SikuliFramework Logger class will create a handler for RobotFramework that uses this formatter. 39 | """ 40 | 41 | def __init__(self): 42 | logging.Formatter.__init__(self, '*%(levelname)s:%(asctime)s* %(message)s') 43 | 44 | def formatTime(self, record, datefmt=None): 45 | """ 46 | Format the time to unix timestamp + milliseconds 47 | """ 48 | 49 | return string.replace('%1.3f' % time.time(), '.', '') 50 | -------------------------------------------------------------------------------- /src/log/robotframework/handler.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import logging 32 | 33 | class Handler(logging.Handler): 34 | def __init__(self): 35 | logging.Handler.__init__(self) 36 | 37 | def emit(self, record): 38 | print self.format(record) -------------------------------------------------------------------------------- /src/log/tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /src/region/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from transform import * 32 | from finder import * -------------------------------------------------------------------------------- /src/region/exception.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from error import SikuliFrameworkException 32 | 33 | class ImageSearchExhausted(SikuliFrameworkException): 34 | pass 35 | 36 | class ImageMissingException(SikuliFrameworkException): 37 | pass 38 | 39 | class FindExhaustedException(SikuliFrameworkException): 40 | pass 41 | -------------------------------------------------------------------------------- /src/region/tests/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /src/region/tests/mockFinder.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from sikuli.Region import Region 32 | from region.finder import FinderAbstract 33 | 34 | class Finder(FinderAbstract): 35 | 36 | baselines = None 37 | callbacks = [] 38 | test = None 39 | state = None 40 | 41 | def __init__(self, entity, region=None, state=None, *args, **kwargs): 42 | object.__init__(self, *args, **kwargs) 43 | 44 | # If we have any callbacks setup, run them! 45 | if len(self.callbacks) > 0: 46 | self.callbacks.pop(0)(self.test, entity=entity, *args, **kwargs) 47 | 48 | self.baselines = {} 49 | self.state = state 50 | 51 | @classmethod 52 | def setTest(cls, test): 53 | cls.test = test 54 | 55 | @classmethod 56 | def addCallback(cls, callback): 57 | cls.callbacks.append(callback) 58 | 59 | def find(self, timeout=0): 60 | return Region(0,0,100,100) 61 | 62 | def getImageNames(self, series=0, state=None, md5=False): 63 | 64 | state = "[" + state + "]" if isinstance(state, str) else "" 65 | 66 | try: 67 | baselines = [] 68 | for baseline in self.baselines[series]: 69 | 70 | if md5: 71 | baselines.append('MD5HASH.png') 72 | else: 73 | baselines.append(baseline + '%s.png' % state) 74 | except KeyError: 75 | pass # No baseline images for this series 76 | 77 | return baselines 78 | 79 | def getLastRegionFound(self): 80 | return Region(0,0,100,100) 81 | 82 | def addBaseline(self, name, series=0): 83 | 84 | try: 85 | self.baselines[series].append(name) 86 | except KeyError: 87 | self.baselines[series] = [] 88 | self.baselines[series].append(name) 89 | 90 | def getState(self): 91 | return self.state 92 | 93 | def getLastSeriesMatched(self): 94 | return 0 95 | 96 | def getLastRegionMatched(self): 97 | return Region(0,0,100,100) 98 | 99 | def setRegion(self, region): 100 | return self 101 | 102 | def __str__(self): 103 | return "RegionFinderMock" 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/region/tests/region.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import unittest 32 | 33 | from sikuli import Region, Location 34 | 35 | class RegionTests(unittest.TestCase): 36 | 37 | 38 | def setUp(self): 39 | #Region.debugPlaybackMode = True 40 | #Region.highlightTime = 2 41 | pass 42 | 43 | def tearDown(self): 44 | pass 45 | 46 | def testSetOffset(self): 47 | 48 | region = Region(100,100,100,100) 49 | region = region.offset(Location(100,100)) 50 | 51 | self.assertEqual(region.getX(), 200) 52 | self.assertEqual(region.getY(), 200) 53 | self.assertEqual(region.getW(), 100) 54 | self.assertEqual(region.getH(), 100) 55 | 56 | 57 | def testSetClickOffset(self): 58 | 59 | region = Region(100,100,100,100) 60 | region.setClickOffset(Location(10,10)) 61 | 62 | # Check that it is set right 63 | location = region.getClickOffset() 64 | self.assertEqual(location.getX(), 10) 65 | self.assertEqual(location.getY(), 10) 66 | 67 | location = region.getClickLocation() 68 | self.assertEqual(location.getX(), 160.0) 69 | self.assertEqual(location.getY(), 160.0) 70 | 71 | 72 | def testRegionCanAddRegion(self): 73 | 74 | region = Region(100,100,100,100) 75 | region = region.add(Region(100,100,200,200)) 76 | 77 | # Width/Height should have changed to 200/200 78 | self.assertEqual(region.getX(), 100) 79 | self.assertEqual(region.getY(), 100) 80 | self.assertEqual(region.getW(), 200) 81 | self.assertEqual(region.getH(), 200) 82 | 83 | def testCreateRegionFromList(self): 84 | 85 | regions = [Region(50,50,50,50), Region(200,50,50,50), Region(200,50,50,50), Region(200,200,50,50)] 86 | 87 | region = Region(regions) 88 | 89 | # Width/Height should have changed to 200/200 90 | self.assertEqual(region.getX(), 50) 91 | self.assertEqual(region.getY(), 50) 92 | self.assertEqual(region.getW(), 200) 93 | self.assertEqual(region.getH(), 200) 94 | 95 | def testCanLimitRegion(self): 96 | 97 | region = Region(50,50,400,400).limit( Region(150,100,150,25) ) 98 | self.assertEqual(region.getX(), 150) 99 | self.assertEqual(region.getY(), 100) 100 | self.assertEqual(region.getW(), 150) 101 | self.assertEqual(region.getH(), 25) 102 | 103 | region = Region(100,100,200,200).limit( Region(50,50,400,400) ) 104 | self.assertEqual(region.getX(), 100) 105 | self.assertEqual(region.getY(), 100) 106 | self.assertEqual(region.getW(), 200) 107 | self.assertEqual(region.getH(), 200) 108 | 109 | 110 | def testCanAddLocationToRegion(self): 111 | 112 | region = Region(100,100,1,1) 113 | 114 | # Check that initialized properly 115 | self.assertEqual(region.getX(), 100) 116 | self.assertEqual(region.getY(), 100) 117 | self.assertEqual(region.getW(), 1) 118 | self.assertEqual(region.getH(), 1) 119 | 120 | region = region.add(Location(50,50)) 121 | 122 | # X,Y Should have changed to 50 123 | self.assertEqual(region.getX(), 50) 124 | self.assertEqual(region.getY(), 50) 125 | 126 | # W,H should have changed to 50 127 | self.assertEqual(region.getW(), 51) 128 | self.assertEqual(region.getH(), 51) 129 | 130 | region = region.add(Location(200,50)) 131 | 132 | # Width/Height should have changed to 200/200 133 | self.assertEqual(region.getX(), 50) 134 | self.assertEqual(region.getY(), 50) 135 | self.assertEqual(region.getW(), 150) 136 | self.assertEqual(region.getH(), 51) 137 | 138 | 139 | region = region.add(Location(200,200)) 140 | 141 | # Width/Height should have changed to 200/200 142 | self.assertEqual(region.getX(), 50) 143 | self.assertEqual(region.getY(), 50) 144 | self.assertEqual(region.getW(), 150) 145 | self.assertEqual(region.getH(), 150) 146 | 147 | 148 | 149 | 150 | 151 | if __name__ == "__main__": 152 | #import sys;sys.argv = ['', 'Test.testName'] 153 | unittest.main() -------------------------------------------------------------------------------- /src/robotframework/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from robotRemoteServer import * 32 | from sikuliFwRfAbstractLib import * 33 | -------------------------------------------------------------------------------- /src/robotframework/common/RegistryLib.py: -------------------------------------------------------------------------------- 1 | #Interpreter: Python 2 | """ 3 | Copyright (c) 2013, SMART Technologies ULC 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 15 | the names of its contributors (Joshua Henn) may be used to endorse or 16 | promote products derived from this software without specific prior 17 | written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 20 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 25 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | from core.lib.robotremoteserver import RobotRemoteServer 32 | import sys 33 | import _winreg 34 | import re 35 | 36 | class RegistryLib(object): 37 | 38 | def setValue(self, key, type, valueName, value): 39 | 40 | # Match a registry key 41 | match = re.search(r"(?P^[a-z0-9_]+)\\(?P[ a-z0-9_\\]*?)$", key, re.IGNORECASE | re.MULTILINE) 42 | 43 | if not match: 44 | raise Exception("Key syntax is invalid") 45 | 46 | try: 47 | keyRes = _winreg.CreateKey(getattr(_winreg, match.group("namespace")), match.group("key")) 48 | _winreg.SetValueEx(keyRes, valueName, None, getattr(_winreg,type), value) 49 | _winreg.CloseKey(keyRes) 50 | print "Key [%s\\%s], setting type [%s] value [%s=%s]" % (match.group("namespace"), match.group("key"), type, valueName, value) 51 | finally: 52 | pass 53 | 54 | 55 | def readValue(self, key, valueName): 56 | 57 | # Match a registry key 58 | match = re.search(r"(?P^[a-z0-9_]+)\\(?P[ a-z0-9_\\]*?)$", key, re.IGNORECASE | re.MULTILINE) 59 | 60 | if not match: 61 | raise Exception("Key syntax is invalid") 62 | 63 | try: 64 | keyRes = _winreg.OpenKey(getattr(_winreg, match.group("namespace")), match.group("key"), 0, _winreg.KEY_ALL_ACCESS) 65 | except WindowsError: 66 | raise Exception("Cannot find registry key [%s]" % key) 67 | 68 | try: 69 | return _winreg.QueryValueEx(keyRes, valueName)[0] 70 | except WindowsError: 71 | raise Exception("Cannot find valueName [%s] in registry key [%s]" % (valueName, match.group("namespace"))) 72 | 73 | _winreg.CloseKey(keyRes) 74 | 75 | def createKey(self, key): 76 | 77 | # Match a registry key 78 | match = re.search(r"(?P^[a-z0-9_]+)\\(?P[ a-z0-9_\\]*?)$", key, re.IGNORECASE | re.MULTILINE) 79 | 80 | if not match: 81 | raise Exception("Key syntax is invalid") 82 | 83 | try: 84 | keyRes = _winreg.CreateKey(getattr(_winreg, match.group("namespace")), key) 85 | _winreg.CloseKey(keyRes) 86 | print "[%s] created." % (key) 87 | finally: 88 | pass 89 | 90 | if __name__ == '__main__': 91 | RobotRemoteServer(RegistryLib(), *sys.argv[1:]) 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/robotframework/common/Selenium2Lib.py: -------------------------------------------------------------------------------- 1 | #Interpreter: Python 2 | """ 3 | Copyright (c) 2013, SMART Technologies ULC 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | * Redistributions of source code must retain the above copyright notice, 10 | this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 15 | the names of its contributors (Joshua Henn) may be used to endorse or 16 | promote products derived from this software without specific prior 17 | written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 20 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 22 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 25 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 26 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 27 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 28 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | """ 31 | from core.lib.robotremoteserver import RobotRemoteServer 32 | import sys 33 | import Selenium2Library 34 | 35 | RobotRemoteServer(Selenium2Library.Selenium2Library(), *sys.argv[1:]) 36 | -------------------------------------------------------------------------------- /src/robotframework/common/Selenium2Server.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from core.lib.robotremoteserver import RobotRemoteServer 31 | import bootstrap 32 | from entities import * 33 | 34 | import os 35 | import sys 36 | import subprocess 37 | import platform 38 | from log import Logger 39 | 40 | 41 | class Selenium: 42 | 43 | vmrunPath = None 44 | log = Logger() 45 | 46 | def __init__(self): 47 | """Also this doc should be in shown in library doc.""" 48 | 49 | def start(self): 50 | 51 | p = subprocess.Popen(['java', '-jar', 'java/selenium-server-standalone-2.21.0.jar'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) 52 | 53 | 54 | if __name__ == '__main__': 55 | #RobotRemoteServer(Selenium(), *sys.argv[1:]) 56 | 57 | s = Selenium() 58 | s.start() -------------------------------------------------------------------------------- /src/robotframework/common/ShellLib.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | import bootstrap # Startup sikulifw 31 | import time 32 | from core.lib.robotremoteserver import RobotRemoteServer 33 | import os 34 | import string 35 | import subprocess 36 | import sys 37 | from log import Logger 38 | 39 | class Command(object): 40 | 41 | workingDir = "" 42 | parameters = None 43 | shellMode = True 44 | 45 | def __init__(self): 46 | self.parameters = [] 47 | 48 | def setWorkingDirectory(self, path): 49 | self.workingDir = path 50 | 51 | def getWorkingDirectory(self): 52 | return os.getcwd() + '/' + self.workingDir 53 | 54 | def setShellMode(self, mode): 55 | self.shellMode = mode 56 | 57 | def getShellMode(self): 58 | return self.shellMode 59 | 60 | def addParameter(self, parameter): 61 | inQuote = False 62 | buildParam = "" 63 | for char in parameter: 64 | 65 | if char == ' ' and len(buildParam) and not inQuote: 66 | self.parameters.append(buildParam) 67 | buildParam = "" 68 | elif char == '"' and not inQuote: 69 | inQuote = True 70 | buildParam = buildParam + char 71 | elif char == '"' and inQuote: 72 | # End of a quote, add the param 73 | inQuote = False 74 | buildParam = buildParam + char 75 | self.parameters.append(buildParam) 76 | buildParam = "" 77 | elif char == ' ' and not len(buildParam): 78 | pass # Don't add whitespace to start of a param 79 | else: 80 | buildParam = buildParam + char 81 | 82 | # If there is left in the build param, add it as a param 83 | if len(buildParam): 84 | self.parameters.append(buildParam) 85 | 86 | def getParameters(self): 87 | 88 | if self.shellMode: 89 | # In shell mode it wants it as a string 90 | return ' '.join(self.parameters) 91 | else: 92 | # Otherwise as an array 93 | return self.parameters 94 | 95 | def __str__(self): 96 | 97 | return ' '.join(self.parameters) 98 | 99 | 100 | 101 | class ShellLib(object): 102 | 103 | log = None 104 | command = None 105 | 106 | def __init__(self): 107 | self.logger = Logger() 108 | 109 | def newCommand(self): 110 | self.command = Command() 111 | 112 | def setWorkingDirectory(self, path): 113 | self.command.setWorkingDirectory(path) 114 | 115 | def addParameter(self, value): 116 | self.command.addParameter(value) 117 | self.logger.info(str(self.command)) 118 | 119 | def enableShellMode(self): 120 | self.command.setShellMode(True) 121 | 122 | def disableShellMode(self): 123 | self.command.setShellMode(False) 124 | 125 | def execute(self): 126 | 127 | self.logger.info("Executing.. [%s] wd=%s" % (self.command, self.command.getWorkingDirectory())) 128 | 129 | p = subprocess.Popen(self.command.getParameters(), shell=self.command.getShellMode(), cwd=self.command.getWorkingDirectory(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) 130 | out, err = p.communicate() 131 | 132 | if out: self.logger.info(out) 133 | if err: self.logger.error(err) 134 | 135 | if p.returncode != 0: 136 | raise Exception("Error occurred while trying to execute console command RC=%d" % p.returncode) 137 | 138 | 139 | if __name__ == "__main__": 140 | RobotRemoteServer(ShellLib(), *sys.argv[1:]) 141 | -------------------------------------------------------------------------------- /src/robotframework/common/ToolsLib.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | from core.lib.robotremoteserver import RobotRemoteServer 31 | import bootstrap # Startup sikulifw 32 | import time 33 | import os 34 | import string 35 | import subprocess 36 | import sys 37 | from log import Logger 38 | import re 39 | 40 | #from log.decorators import Formatter 41 | from config import Config 42 | 43 | 44 | class ToolsLib(object): 45 | 46 | log = None 47 | artifactPath = "install" 48 | 49 | def __init__(self): 50 | 51 | self.log = Logger() 52 | 53 | def findFile(self, needle, extension): 54 | 55 | # Find the zip file (We have to find like this because the date changes) 56 | found = False 57 | for file in os.listdir(self.artifactPath): 58 | if string.find(file, needle) >= 0 and re.search(extension + "$", file, re.IGNORECASE): 59 | found = True 60 | break; 61 | 62 | if not found: 63 | self.log.debug("files=%s" % ','.join(os.listdir(self.artifactPath))) 64 | raise Exception("Unable to find a zip file that has [%s] in the name with [%s] extension" % (needle, extension)) 65 | 66 | # Get the name of the file minus the extension 67 | reobj = re.compile(r"(?P.*?)(?P\.[0-9a-z]*$)", re.IGNORECASE) 68 | return reobj.search(file).group("filename") 69 | 70 | 71 | 72 | if __name__ == "__main__": 73 | RobotRemoteServer(ToolsLib(), *sys.argv[1:]) 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/robotframework/common/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | -------------------------------------------------------------------------------- /src/robotframework/common/tests/ShellLib.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import unittest 32 | from keywords.common.ShellLib import * 33 | 34 | class Test(unittest.TestCase): 35 | 36 | 37 | def setUp(self): 38 | pass 39 | 40 | 41 | def tearDown(self): 42 | pass 43 | 44 | 45 | def testCanAddBasicParameters(self): 46 | 47 | command = Command() 48 | command.setShellMode(False) 49 | command.addParameter("param1") 50 | command.addParameter("param2") 51 | command.addParameter("param3") 52 | 53 | self.assertEqual(command.getParameters(), ['param1','param2','param3']) 54 | 55 | 56 | def testCanAddCompoundParameters(self): 57 | 58 | command = Command() 59 | command.setShellMode(False) 60 | command.addParameter("param1 param2") 61 | command.addParameter("param3") 62 | command.addParameter("param4") 63 | 64 | self.assertEqual(command.getParameters(), ['param1','param2','param3','param4']) 65 | 66 | def testCanAddQuoteParameter(self): 67 | 68 | command = Command() 69 | command.setShellMode(False) 70 | command.addParameter('"quote param"') 71 | 72 | self.assertEqual(command.getParameters(), ['quote param']) 73 | 74 | def testCanAddCompoundQuoteParameter(self): 75 | 76 | command = Command() 77 | command.setShellMode(False) 78 | command.addParameter('param1 "quote param2" param3') 79 | 80 | self.assertEqual(command.getParameters(), ['param1','quote param2','param3']) 81 | 82 | def testShell(self): 83 | 84 | command = Command() 85 | command.addParameter('msiexec.exe') 86 | command.addParameter(unicode('/i "test.msi"')) 87 | 88 | print str(command) 89 | 90 | 91 | if __name__ == "__main__": 92 | #import sys;sys.argv = ['', 'Test.testName'] 93 | unittest.main() 94 | 95 | -------------------------------------------------------------------------------- /src/robotframework/common/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/smysnk/sikuli-framework/e1590699948733aa5ee21ef92188eee03e98d1d9/src/robotframework/common/tests/__init__.py -------------------------------------------------------------------------------- /src/robotframework/common/tests/tools.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | import unittest 32 | from keywords.common.Tools import Tools 33 | 34 | class Test(unittest.TestCase): 35 | 36 | 37 | def setUp(self): 38 | pass 39 | 40 | 41 | def tearDown(self): 42 | pass 43 | 44 | 45 | def testName(self): 46 | 47 | tools = Tools() 48 | 49 | 50 | if __name__ == "__main__": 51 | #import sys;sys.argv = ['', 'Test.testName'] 52 | unittest.main() -------------------------------------------------------------------------------- /src/robotframework/draw_callback_patch.html: -------------------------------------------------------------------------------- 1 | 20 | -------------------------------------------------------------------------------- /src/tests/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | from log.robotFramework import Logger as RobotLogger 3 | from log import * 4 | from entity import Entity 5 | from region.tests.mockFinder import Finder 6 | from log.formatter import Formatter 7 | from config import Config 8 | from entity.searcher import Searcher 9 | from tests.mockTool import Tool 10 | import unittest 11 | from entity.multiResultProxy import MultiResultProxy 12 | 13 | Logger.setRobotLogger(RobotLogger()) 14 | Logger.setFormatter(Formatter) 15 | 16 | Formatter.setTool(Tool) 17 | Formatter.setConfig(Config) 18 | 19 | Entity.setLogger(Logger) 20 | Entity.setRegionFinderStrategy(Finder) 21 | Entity.setSearcherStrategy(Searcher) 22 | Entity.setMultiResultProxyStrategy(MultiResultProxy) 23 | 24 | MultiResultProxy.setEntitySearcher(Searcher) -------------------------------------------------------------------------------- /src/tests/mockTool.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | class Tool(object): 32 | 33 | assetName = "MD5HASH.png" 34 | 35 | @classmethod 36 | def setAssetName(cls,name): 37 | cls.assetName = name 38 | 39 | @classmethod 40 | def saveAsset(cls, source): 41 | return cls.assetName -------------------------------------------------------------------------------- /src/tool.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from md5 import md5 32 | import shutil 33 | 34 | 35 | class Tool: 36 | 37 | destDir = None 38 | 39 | @classmethod 40 | def setDestDir(cls, destDir): 41 | cls.destDir = destDir 42 | 43 | @classmethod 44 | def saveAsset(cls, sourcePath): 45 | """ 46 | Copy source file with the name renamed as MD5 of the file contents -> md5.ext 47 | Expects: file with 3 letter extension 48 | 49 | This is used so that we don't duplicate images. 50 | Say for instance the same part of the screen has been captured twice, but it has not changed. 51 | Instead of saving two pictures, we just save one since they would have the same MD5. 52 | """ 53 | 54 | f = file(sourcePath,'rb') 55 | destFile = md5(f.read()).hexdigest() + sourcePath[-4:] 56 | shutil.copy(sourcePath, cls.destDir + destFile) 57 | 58 | return destFile 59 | -------------------------------------------------------------------------------- /src/wrapper.py: -------------------------------------------------------------------------------- 1 | """ 2 | Copyright (c) 2013, SMART Technologies ULC 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are 7 | met: 8 | * Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in the 12 | documentation and/or other materials provided with the distribution. 13 | * Neither the name of the Copyright holder (SMART Technologies ULC) nor 14 | the names of its contributors (Joshua Henn) may be used to endorse or 15 | promote products derived from this software without specific prior 16 | written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER (SMART Technologies 19 | ULC) "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 21 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 24 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 27 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | """ 30 | 31 | from org.sikuli.script import Location, Pattern 32 | import types 33 | from sikuli import Env, Region 34 | from org.sikuli.script import Region as JRegion 35 | from org.sikuli.script import Env as JEnv 36 | #from config import Config 37 | #from logger import Logger 38 | from sikuli.Sikuli import capture 39 | 40 | # =============================================== # 41 | # Overwritten sikuli methods # 42 | # =============================================== # 43 | 44 | # function for calling native sikuli methods 45 | def sikuli_method(name, *args, **kwargs): 46 | return sys.modules['sikuli.Sikuli'].__dict__[name](*args, **kwargs) 47 | 48 | # overwritten Screen.exists method 49 | def exists(target, timeout=None): 50 | addFoundImage(getFilename(target)) 51 | return sikuli_method('exists', target, timeout) 52 | 53 | # =============================================== # 54 | # Overwritten sikuli classes # 55 | # =============================================== # 56 | 57 | @staticmethod 58 | def EnvGetOSVersion(fullName=None): 59 | if not fullName: 60 | return Env.oldGetOSVersion(); 61 | elif Env.oldGetOSVersion() == '5.1': 62 | return 'XP' 63 | elif Env.oldGetOSVersion() == '6.0': 64 | return 'Vista' 65 | elif Env.oldGetOSVersion() == '6.1': 66 | return 'Win7' 67 | 68 | Env.oldGetOSVersion = Env.getOSVersion 69 | Env.getOSVersion = EnvGetOSVersion 70 | 71 | ## Java Region patching 72 | def add(self, operand): 73 | 74 | # If we're trying to add None, just return the original region 75 | if not operand: 76 | return self 77 | 78 | regions = [self, operand] 79 | 80 | # more than one region, get min/max region 81 | minX, minY = 9999, 9999 82 | maxX, maxY = -9999, -9999 83 | for region in regions: 84 | if region.getX() < minX: minX = int(region.getX()) 85 | if region.getY() < minY: minY = int(region.getY()) 86 | 87 | # If this is a region type 88 | if hasattr(region, "getW") and hasattr(region, "getH"): 89 | if (region.getX() + region.getW()) > maxX: maxX = region.getX() + region.getW() 90 | if (region.getY() + region.getH()) > maxY: maxY = region.getY() + region.getH() 91 | else: 92 | if region.getX() > maxX: maxX = int(region.getX()) 93 | if region.getY() > maxY: maxY = int(region.getY()) 94 | 95 | return Region(minX, minY, maxX-minX, maxY-minY) 96 | 97 | JRegion.add = add 98 | 99 | # Java Region patching 100 | def limit(self, operand): 101 | 102 | # If we're trying to limit None, return original 103 | if not operand: 104 | return self 105 | 106 | x1 = self.getX() if self.getX() > operand.getX() else operand.getX() 107 | y1 = self.getY() if self.getY() > operand.getY() else operand.getY() 108 | x2 = (self.getX() + self.getW()) if (self.getX() + self.getW()) < (operand.getX() + operand.getW()) else (operand.getX() + operand.getW()) 109 | y2 = (self.getY() + self.getH()) if (self.getY() + self.getH()) < (operand.getY() + operand.getH()) else (operand.getY() + operand.getH()) 110 | 111 | # Check region is valid positive 112 | if x2-x1 < 0 or y2-y1 < 0: 113 | raise Exception("Region %s is outside the bounds of the ParentRegion %s" % (self, operand)) 114 | 115 | 116 | return Region(x1, y1, x2-x1, y2-y1) 117 | 118 | JRegion.limit = limit 119 | 120 | def offset(self, operand): 121 | 122 | self.setX(self.getX() + operand.getX()) 123 | self.setY(self.getY() + operand.getY()) 124 | 125 | return self 126 | 127 | ## 128 | def regionInit(self, operand, *args, **kargs): 129 | 130 | # Handle a list of regions 131 | if isinstance(operand, list): 132 | 133 | region = None 134 | 135 | for item in operand: 136 | 137 | if region: 138 | region = region.add(item) 139 | else: 140 | region = item 141 | 142 | self.oldInit(region, *args, **kargs) 143 | 144 | else: 145 | self.oldInit(operand, *args, **kargs) 146 | 147 | JRegion.oldInit = JRegion.__init__ 148 | JRegion.__init__ = regionInit 149 | 150 | 151 | ## Region patching 152 | #JRegion.timeout = Config.regionTimeout 153 | JRegion.clickOffset = Location(0,0) 154 | 155 | # Define setClickOffset 156 | def setClickOffset(self, offset): 157 | 158 | assert isinstance(offset, Location) 159 | self.clickOffset = offset 160 | 161 | JRegion.setClickOffset = setClickOffset 162 | 163 | # Define getClickLocation 164 | def getClickLocation(self): 165 | 166 | x = self.x + (self.w/2) + self.clickOffset.getX() 167 | y = self.y + (self.h/2) + self.clickOffset.getY() 168 | 169 | return Location(x, y) 170 | 171 | JRegion.getClickLocation = getClickLocation 172 | 173 | 174 | # Define getClickLocation 175 | def getClickOffset(self): 176 | 177 | return self.clickOffset 178 | 179 | JRegion.getClickOffset = getClickOffset 180 | 181 | --------------------------------------------------------------------------------