Giter Club home page Giter Club logo

robotframework-imagehorizonlibrary's Introduction

ImageHorizonLibrary

This Robot Framework library provides the facilities to automate GUIs based on image recognition similar to Sikuli. This library wraps pyautogui to achieve this.

For non pixel perfect matches, there is a feature called confidence level that comes with a dependency OpenCV (python package: opencv-python). This functionality is optional - you are not required to install opencv-python package if you do not use confidence level.

Keyword documentation

Keyword Documentation

Travis CI

Travis CI

image

Prerequisites

On Ubuntu, you need to take special measures to make the screenshot functionality to work correctly. The keyboard functions might not work on Ubuntu when run in VirtualBox on Windows.

Development

Installation

If you have pip, installation is straightforward:

$ pip install robotframework-imagehorizonlibrary

This will automatically install dependencies as well as their dependencies.

Windows

ImageHorizonLibrary should work on Windows "out-of-the-box". Just run the commands above to install it.

OSX

NOTICE ImageHorizonLibrary does not currently work with XCode v.8. Please use a previous version.

You additionally need to install these for pyautogui:

$ pip install pyobjc-core pyobjc

For these, you need to install XCode

Linux

You additionally need to install these for pyautogui:

$ sudo apt-get install python-dev python-xlib

You might also need, depending on your Python distribution, to install:

$ sudo apt-get install python-tk

If you are using virtualenv, you must install python-xlib manually to the virtual environment for pyautogui:

$ pip install python-xlib-<latest version>.tar.gz

Running unit tests

$ python tests/utest/run_tests.py [verbosity=2]

Running acceptance tests

Additionally to unit test dependencies, you also need OpenCV, Eel, scrot and Chrome/Chromium browser. OpenCV is used because this tests are testing also confidence level. Browser is used by Eel for cross-platform GUI demo application. scrot is used for capturing screenshots.

$ pip install opencv-python eel

To run tests, run this command:

$ python tests/atest/run_tests.py

Updating Docs

To regenerate documentation (doc/ImageHorizonLibrary.html), use this command:

$ python -m robot.libdoc -P ./src ImageHorizonLibrary doc/ImageHorizonLibrary.html

robotframework-imagehorizonlibrary's People

Contributors

jonkoser avatar matejc avatar mrako avatar tattoo avatar vrchmvgx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robotframework-imagehorizonlibrary's Issues

Feature Request: Add optional timeout on functions that use reference_image

This feature request (well more a suggestion) is aimed primarily at the Click * Image and Does Exist keywords.

This feature would make imagehorizonlibrary behave more similarly to SeleniumLibrary and BrowserLibrary in that they both have a timeout waiting for the element to exist rather than failing immediately if the element is not already on the screen. I believe this change would make imagehorizonlibrary more user friendly especially to people new to this library.

My proposed solution would be simply to replace the self.locate with self.wait_for in the Click Image functions and probably also the Does Exist function. An optional timeout argument would be added to be passed to the wait_for function, this would be by default be set to 0 so that the current behaviour of these keywords is unchanged.

Obviously Issue #60 would need to be fixed first for this to work.

If this feature is also included on the locate keyword function it would make wait for redundant, not sure if that is a good or bad thing, but there is the possibility of consolidating those two.

An additional a keyword for set default timeout could also be added to change the default timeout from 0 to a value that the user chooses.

Is it possible to add headless run ?

Well i know it is technically possible with some workaround. I just hacked the library to add test running in xvfb. This is a quick and (realy) dirty implementation.

modify the init.py at the root library folder
`
...

required modules

import os
import Xlib.display
from pyvirtualdisplay.smartdisplay import SmartDisplay

new method to add running test in xvfb

def start_xvfb(self, width=1920, height=1080, depth=24):
'''Allow to execute tests in a virtual display (Xvfb)'''
LOGGER.info("STARTING VIRTUAL DISPLAY : %sx%sx%s " % (width, height, depth))
display = SmartDisplay(visible=0, size=(width, height), color_depth=depth)
display.start()
SmartDisplay()
# this is the tricky part !
ag._pyautogui_x11._display = Xlib.display.Display(os.environ["DISPLAY"])
LOGGER.info("DISPLAY IS : %s " % os.environ["DISPLAY"])
....
`

All of this is just a copy/paste implementation from this post : http://fredtantini.free.fr/blog/index.php?article58/automatiser-des-actions-avec-selenium-pyautogui-et-xvfb

Of course this is just a proof of concept that just work (except you have to take care of windows decoration) and just for Gnu/linux distro.

Ability to have multiple versions of an reference image

It would be handy if IHL could automatically check screenshot against multiple versions of same reference image. One idea could be to have the reference image name to be either a .png file or a folder -- in latter case, all images from under that folder could be tried.

For example, given:

reference_images/
    ├── button_cancel.png
    ├── button_save.png
    ├── popup_notification/
    │   ├── linux.png
    │   ├── osx.png
    │   └── windows.png
    └── window_title_main.png

If one would do:

Wait for    popup notification

then IHL would try each picture from that folder.

Main motivation is that right now, you would need to do this handling inside Robot Framework or force you to make a library yourself.

TypeError: 'NoneType' object has no attribute '__getitem__'

Facing "TypeError: 'NoneType' object has no attribute 'getitem' "when running below code:

*** Settings ***
Library BuiltIn
Library OperatingSystem
Library Process
Library AutoItLibrary
Library Collections
Library ImageHorizonLibrary reference_folder=c:\downloads

*** Test Case ***
Run Application
App
*** KeyWords ***
App
AutoItLibrary.Run C:\Downloads\CinebenchR20\app.exe
Sleep 5s
Locate file
Click Image file
Sleep 1s
locate selectall
Click Image selectall

Setup details:
Python v2.7
Pillow==2.9.0
PyAutoGUI==0.9.42
PyGetWindow==0.0.4
robotframework==3.1.2
robotframework-autoitlibrary==1.2.4
robotframework-imagehorizonlibrary==0.1

Locate Improvement ability to give hints where to look for pattern

I think in some big resolution to improve performance it would be nice to give option to give hints where to start looking for pattern, when hints failed resume using standard approach.
I see two solutions
first give rectangle where to start to search (10,10| 200|200)
or general information about sector like TOP, CENTER,BOTTOM, LEFT, RIGHT ex. BOTTOM -RIGHT or TOP-CENTER.
And Information about which display.

Image Keywords not working on Mac

Following Keywords fail:

Locate
Wait for
Click Image

Error is:

ImageNotFoundException: Reference image "myimage.png" was not found on screen

If I use an Image inside VSCode, where I also execute the Robot Tests then ImageHorizonLibrary find the Image. If I use any Image which is not part of VSCode ( eg. Finder, any Apps, etc. ) then ImageHorizonLibrary will NOT find the Image provided and result in ImageNotFoundException even if the App which I used to take a Screenshot from has the Focus.

I also saw that there will be created a Screenshot TestLogicAUQT-screenshot-1.png. How is that working ?

image

This Image shows an empty Desktop with Logic Pro active not showing any Dialogs.

image

If I change to Finder while Test is running I get the same empty Screenshot showing the Desktop only Finder is focused then. It seems the ImageHorizonLibrary is not able to see Dialogs / Windows of an App.

Is there a way to also use Images outside of VSCode ?

Cheers
Dirk

Code Example

TestLogicAUQT.robot

*** Settings ***
Library  Libraries/LibDaw.py
Library  ImageHorizonLibrary  reference_folder=${CURDIR}${/}Data${/}UIAutomationImages

*** Test Cases ***
Test Logic Pro AU QT
  Open DAW  Logic Pro X
  Locate  LPX_EmptyProject  # <-- Doesn't work; Screenshot from Logic
  Wait for  Tutorials  # <-- Doesn't work; Screenshot from Logic
  Wait for  Facts  # <-- Works as it is a Screenshot from VScode
  Wait for  Facts2  # <-- Doesn't work; Screenshot from Finder

Versions

MacOS Catalina 10.15.7 (19H524) on Intel
Python 3.8.7
MouseInfo==0.1.3
Pillow==8.1.2
PyAutoGUI==0.9.52
PyGetWindow==0.0.9
PyMsgBox==1.0.9
pyobjc==7.1
pyobjc-core==7.1
pyobjc-framework-Accounts==7.1
pyobjc-framework-AddressBook==7.1
pyobjc-framework-AdSupport==7.1
pyobjc-framework-AppleScriptKit==7.1
pyobjc-framework-AppleScriptObjC==7.1
pyobjc-framework-ApplicationServices==7.1
pyobjc-framework-AuthenticationServices==7.1
pyobjc-framework-AutomaticAssessmentConfiguration==7.1
pyobjc-framework-Automator==7.1
pyobjc-framework-AVFoundation==7.1
pyobjc-framework-AVKit==7.1
pyobjc-framework-BusinessChat==7.1
pyobjc-framework-CalendarStore==7.1
pyobjc-framework-CFNetwork==7.1
pyobjc-framework-CloudKit==7.1
pyobjc-framework-Cocoa==7.1
pyobjc-framework-Collaboration==7.1
pyobjc-framework-ColorSync==7.1
pyobjc-framework-Contacts==7.1
pyobjc-framework-ContactsUI==7.1
pyobjc-framework-CoreAudio==7.1
pyobjc-framework-CoreAudioKit==7.1
pyobjc-framework-CoreBluetooth==7.1
pyobjc-framework-CoreData==7.1
pyobjc-framework-CoreHaptics==7.1
pyobjc-framework-CoreLocation==7.1
pyobjc-framework-CoreMedia==7.1
pyobjc-framework-CoreMediaIO==7.1
pyobjc-framework-CoreMIDI==7.1
pyobjc-framework-CoreML==7.1
pyobjc-framework-CoreMotion==7.1
pyobjc-framework-CoreServices==7.1
pyobjc-framework-CoreSpotlight==7.1
pyobjc-framework-CoreText==7.1
pyobjc-framework-CoreWLAN==7.1
pyobjc-framework-CryptoTokenKit==7.1
pyobjc-framework-DeviceCheck==7.1
pyobjc-framework-DictionaryServices==7.1
pyobjc-framework-DiscRecording==7.1
pyobjc-framework-DiscRecordingUI==7.1
pyobjc-framework-DiskArbitration==7.1
pyobjc-framework-DVDPlayback==7.1
pyobjc-framework-EventKit==7.1
pyobjc-framework-ExceptionHandling==7.1
pyobjc-framework-ExecutionPolicy==7.1
pyobjc-framework-ExternalAccessory==7.1
pyobjc-framework-FileProvider==7.1
pyobjc-framework-FileProviderUI==7.1
pyobjc-framework-FinderSync==7.1
pyobjc-framework-FSEvents==7.1
pyobjc-framework-GameCenter==7.1
pyobjc-framework-GameController==7.1
pyobjc-framework-GameKit==7.1
pyobjc-framework-GameplayKit==7.1
pyobjc-framework-ImageCaptureCore==7.1
pyobjc-framework-IMServicePlugIn==7.1
pyobjc-framework-InputMethodKit==7.1
pyobjc-framework-InstallerPlugins==7.1
pyobjc-framework-InstantMessage==7.1
pyobjc-framework-Intents==7.1
pyobjc-framework-IOSurface==7.1
pyobjc-framework-iTunesLibrary==7.1
pyobjc-framework-LatentSemanticMapping==7.1
pyobjc-framework-LaunchServices==7.1
pyobjc-framework-libdispatch==7.1
pyobjc-framework-LinkPresentation==7.1
pyobjc-framework-LocalAuthentication==7.1
pyobjc-framework-MapKit==7.1
pyobjc-framework-MediaAccessibility==7.1
pyobjc-framework-MediaLibrary==7.1
pyobjc-framework-MediaPlayer==7.1
pyobjc-framework-MediaToolbox==7.1
pyobjc-framework-Metal==7.1
pyobjc-framework-MetalKit==7.1
pyobjc-framework-MetalPerformanceShaders==7.1
pyobjc-framework-ModelIO==7.1
pyobjc-framework-MultipeerConnectivity==7.1
pyobjc-framework-NaturalLanguage==7.1
pyobjc-framework-NetFS==7.1
pyobjc-framework-Network==7.1
pyobjc-framework-NetworkExtension==7.1
pyobjc-framework-NotificationCenter==7.1
pyobjc-framework-OpenDirectory==7.1
pyobjc-framework-OSAKit==7.1
pyobjc-framework-OSLog==7.1
pyobjc-framework-PencilKit==7.1
pyobjc-framework-Photos==7.1
pyobjc-framework-PhotosUI==7.1
pyobjc-framework-PreferencePanes==7.1
pyobjc-framework-PushKit==7.1
pyobjc-framework-Quartz==7.1
pyobjc-framework-QuickLookThumbnailing==7.1
pyobjc-framework-SafariServices==7.1
pyobjc-framework-SceneKit==7.1
pyobjc-framework-ScreenSaver==7.1
pyobjc-framework-ScriptingBridge==7.1
pyobjc-framework-SearchKit==7.1
pyobjc-framework-Security==7.1
pyobjc-framework-SecurityFoundation==7.1
pyobjc-framework-SecurityInterface==7.1
pyobjc-framework-ServiceManagement==7.1
pyobjc-framework-Social==7.1
pyobjc-framework-SoundAnalysis==7.1
pyobjc-framework-Speech==7.1
pyobjc-framework-SpriteKit==7.1
pyobjc-framework-StoreKit==7.1
pyobjc-framework-SyncServices==7.1
pyobjc-framework-SystemConfiguration==7.1
pyobjc-framework-SystemExtensions==7.1
pyobjc-framework-UserNotifications==7.1
pyobjc-framework-VideoSubscriberAccount==7.1
pyobjc-framework-VideoToolbox==7.1
pyobjc-framework-Vision==7.1
pyobjc-framework-WebKit==7.1
pyperclip==1.8.2
PyRect==0.1.4
PyScreeze==0.1.26
PyTweening==1.0.3
robotframework==3.1.1
robotframework-imagehorizonlibrary==1.0
rubicon-objc==0.4.0

mouse_down/mouse_up do not use pyautogui correctly

interaction/_mouse.py passes the selected button to pyautogui as the first positional argument:

    def mouse_down(self, button='left'):
        '''Presses specidied mouse button down'''
        ag.mouseDown(button)

    def mouse_up(self, button='left'):
        '''Releases specified mouse button'''
        ag.mouseUp(button)

However, in pyautogui, the first positional argument is x:

def mouseDown(x=None, y=None, button='left', duration=0.0, tween=linear, pause=None, _pause=True):

This means that the button argument, such as 'left', is passed as x. In pyautogui, this counts as passing a location tuple, which is expected to be (x, y), and because 'left' passes the collections.Sequence check, it is treated as a four-character sequence, causing an exception:

def _unpackXY(x, y):
    """If x is a sequence and y is None, returns x[0], y[0]. Else, returns x, y.
    On functions that receive a pair of x,y coordinates, they can be passed as
    separate arguments, or as a single two-element sequence.
    """
    if isinstance(x, collections.Sequence):
        if len(x) == 2:
            if y is None:
                x, y = x
            else:
                raise ValueError('When passing a sequence at the x argument, the y argument must not be passed (received {0}).'.format(repr(y)))
        else:
            raise ValueError('The supplied sequence must have exactly 2 elements ({0} were received).'.format(len(x)))
    else:
        pass

    return x, y

Screen scaling factor (Screen Scaling on Windows / Retina Display on Mac)

Well this is frustrating,

I was trying to set up some basic tests for issues #60 and #61 before I start making changes and I encountered the "retina display issue" when trying to use Click Image.

Did a little research, and found that the upstream pyautogui is the cause, there is a known issue for this #589 where a workaround is provided so they closed the issue, so it looks like if we want IHL to behave as users would expect then we need to handle it by implementing the workaround.

I also found this issue impacts Windows machines when screen scaling is enabled, while on Mac's the Retina display means the co-ordinates are always double (200%) what they need to be, with windows the scaling factor can vary between 100% and 500% times with typical values being 125%, 150%, 175%, 200%

Fortunately the workaround provided pixelRatio = pyautogui.screenshot().size[0]/pyautogui.size().width does give us the ratio, so it's a simple matter of dividing the x and y values from pyautogui by the pixelRatio and returning the new co-ordinates.

Also fortunately the workaround doesn't need any additional python modules so it's a minimal impact.

I will submit a fix for this issue soon.

Bug: Launch application on windows 7 (32-bit)

When using Launch application -keyword and path contains "-", you'll have to place the whole path inside quotation marks, otherwise you will end up with "[Error 2] The system cannot find the file specified".

Not working example: Launch Application C:${/}Foo-bar${/}foobar.exe
Working example: Launch Application "C:${/}Foo-bar${/}foobar.exe"

Compare multiple images different color depth

My application should work with different color settings, from 32 - 16bit. Now if I have image taken with 32bit and my display bit depth is set to 24, the reference image is not found. To work a round this problem, I could do something like this:

| ${status} = | Run Keyword And Return Status | ImageHorizonLibrary.Wait For | image32bit.png |
| ${status} = | Run Keyword Unless |  ${status} | Run Keyword And Return Status | ImageHorizonLibrary.Wait For | image24bit.png |
| Run Keyword Unless |  ${status} | ImageHorizonLibrary.Wait For | image16bit.png |

Which comes quite hard and difficult to read and maintain. I was thinking, would be possible to create a keyword that would take multiple images as an argument and check them one by one, Something like this:

| ImageHorizonLibrary.Wait For Images | timeout=30 | image32bit.png | image24bit.png | image16bit.png |

Would this be feasible feature?

I am sure about the keyword name, should is new new keyword needed at all or should the existing keyword modified to support varargs?

pip install robotframework-ImageHorizonLibrary failed on python 2.7

pip install robotframework-ImageHorizonLibrary failed on python 2.7 with below error:

ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "", line 1, in
File "c:\users\user\appdata\local\temp\pip-install-py9pto\pygetwindow\setup.py", line 10, in
with open('README.md', 'r', encoding='utf-8') as fh:
TypeError: 'encoding' is an invalid keyword argument for this function
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in c:\users\useri\appdata\local\temp\pip-install-py9pto\pygetwindow\

Setup details:

Robot Framework 3.1.2 (Python 2.7.16 on win32)

Installation with Python3 doesn't work

Trying to install with Python 3.x gives the following error message:

$ pip3 install robotframework-imagehorizonlibrary
Collecting robotframework-imagehorizonlibrary
Using cached robotframework-imagehorizonlibrary-0.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/hy/kt73qtfj3rvg6j_zzt0vjt4c0000gn/T/pip-build-9tqxbdjt/robotframework-imagehorizonlibrary/setup.py", line 8, in
execfile('src/ImageHorizonLibrary/version.py')
NameError: name 'execfile' is not defined

Getting "WindowsError: [Error 5] Access is denied." for Click, Click Image and Dobule Click

I am opening a web page which has third party flash contents.
I am error "WindowsError: [Error 5] Access is denied." for Click, Click Image and Double Click. In this case, It seem they are doing their job but after doing the action they are getting this error.

I run the same keywords with "Run Keyword And Ignore Error" and they seems to be doing their job, but with error. But script continued due to "Run Keyword And Ignore Error". Any idea what is causing this and how can I fix this. I have the admin rights of my system.

When running ImageHorizonLibrary.Take A Screenshot keyword, path to the image should relative and not absolute

When I run my tests in CI, I do not want to store the the results in the job which did the actually running. I move the result to different places and even to outside of the CI. But because the ImageHorizonLibrary.Take A Screenshot keyword saves the paths to image as absolute paths, the images are not anymore shown when I move the log.html to a different folder structure.

Example when I save the Robot Framework results in /path/to/workspace/output/ folder, then with ImageHorizonLibrary.Take A Screenshot keyword the DOM is like this:

<img src="/path/to/workspace/output/filename-1.png" width="100%">`

But it should be like this:

<img src="filename-1.png" width="100%">

Example in Selenium2Library the same logic is done in here: https://github.com/robotframework/Selenium2Library/blob/master/src/Selenium2Library/keywords/screenshot.py#L115

Tests on OSX can not proceed

There is an issue with running OSX tests on Travis-CI, the permission popup is stealing input focus from the test app, like seen on the screenshot:

travis-xcode-10-2

Error:
'' cannot be converted to an integer: ValueError: invalid literal for int() with base 10: ''

Calculator
    Set Confidence      0.9
    Launch application    python tests/atest/calculator/calculator.py
    ${location1}=    Wait for    inputs.png
    Click to the above of     ${location1}    20
    Type    1010
    Click to the below of     ${location1}    20
    Type    1001
    ${location2}=    Locate    or_button.png
    Click to the below of     ${location2}    0
    Click to the below of     ${location2}    50
    ${result}=    Copy
    Take A Screenshot                    <-- Screenshot taken here
    Should be equal as integers    ${result}    1011  <-- Error happens right here
    Click Image     close_button.png
    [Teardown]    Terminate application

I have sent an issue to Travis-CI support.

Image captured for google chrome does not work for firefox

I have html5 canvas and I have captured small rectangle from it. It works fine google chrome (which I think I used to capture image) but firefox it does not. I tried checking the difference of shades, size etc but I could not see any difference in which component is being randered on canvas.

"Does exist" returns always true

"Does exist" passes every single time, even if the reference image is not visible on the screen.

Problem could be that "except" -part is never reached, because "return bool" is executed every single time:
try:
return bool(self._locate(reference_image, log_it=False))
except ImageNotFoundException:
return False

Getting error while installing it on MAC

username$ sudo pip install robotframework-imagehorizonlibrary
Password:
The directory '/Users/username/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/username/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting robotframework-imagehorizonlibrary
Downloading robotframework-imagehorizonlibrary-0.1.tar.gz
Requirement already satisfied (use --upgrade to upgrade): robotframework>=2.8 in /usr/local/lib/python2.7/site-packages (from robotframework-imagehorizonlibrary)
Collecting pyautogui>=0.9.30 (from robotframework-imagehorizonlibrary)
Downloading PyAutoGUI-0.9.33.zip (55kB)
100% |████████████████████████████████| 61kB 301kB/s
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/private/tmp/pip-build-1jyQFz/pyautogui/setup.py", line 6, in
version=import('pyautogui').version,
File "pyautogui/init.py", line 110, in
from . import _pyautogui_osx as platformModule
File "pyautogui/_pyautogui_osx.py", line 4, in
import Quartz
ImportError: No module named Quartz

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /private/tmp/pip-build-1jyQFz/pyautogui/

Feature Request: Set Keyword On Failure

A keyword from selenium library that I found quite useful was Register Keyword To Run On Failure.

This feature request is for the equivalent keyword in IHL. I am aware you can set the keyword_on_failure at import, but having the keyword allows you to temporarily change the keyword_on_failure and then change it back.

Background:
Here is a link to my forum post where I explained the situation where this functionality is useful.

I will provide a PR for this feature request.

using rfdebug of robotframework-debuglibrary to import this library gives error

rfdebug

robot debugH9MeJO

RFDEBUG REPL

Enter interactive shell
Only accepted plain text format keyword seperated with two or more spaces.
Type "help" for more information.
Import Library ImageHorizonLibrary_
RFDEBUG REPL | FAIL |
UnicodeEncodeError: 'ascii' codec can't encode character u'\u2318' in position 44: ordinal not in range(128)
robot debugH9MeJO | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed

Output: None

No way to successfully import under python 3.7

Got the following exception when executing the example file "calculator.robot" after executing "python setup.py install":
Additional info: Following exception has been thrown:
Traceback (most recent call last):
File "C:\Users\ADMINI1\AppData\Local\Temp\RobotTempDir2110408418075580461\robot_session_server.py", line 43, in inner
result['result'] = func(*args, **kwargs)
File "C:\Users\ADMINI
1\AppData\Local\Temp\RobotTempDir2110408418075580461\robot_session_server.py", line 105, in inner
return to_call(*args, **kwargs)
File "C:\Users\ADMINI1\AppData\Local\Temp\RobotTempDir2110408418075580461\robot_session_server.py", line 138, in inner
return to_call(*args, **kwargs)
File "C:\Users\ADMINI
1\AppData\Local\Temp\RobotTempDir2110408418075580461\robot_session_server.py", line 78, in inner
return func(*args, **kwargs)
File "C:\Users\ADMINI1\AppData\Local\Temp\RobotTempDir2110408418075580461\robot_session_server.py", line 182, in get_classes_from_module
return red_module_classes.get_classes_from_module(module_location)
File "C:\Users\ADMINI
1\AppData\Local\Temp\RobotTempDir2110408418075580461\red_module_classes.py", line 25, in get_classes_from_module
inside_file_names = module_names_collector._try_to_find_names_in_module(module_name, module_location)
File "C:\Users\ADMINI~1\AppData\Local\Temp\RobotTempDir2110408418075580461\red_module_classes.py", line 188, in _try_to_find_names_in_module
with open(module_location, 'r', encoding='utf-8') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'F:\ProgramData\Anaconda3\lib\site-packages\robotframework_imagehorizonlibrary-0.2_devel-py3.7.egg\ImageHorizonLibrary\init.py'

Python 3.X support

Since Python 2.X is End of life on 1 Jan 2020, it will be great if we can add support for Python 3.X

Wait For will error if timeout is too small

I was looking at the code for the wait_for function and I believe that if the timeout is too small this function will always error.

If the timeout is 0 then the while loop will not be entered and self._locate will never be called, therefore location will remain none and ImageNotFoundException will be called, i'm not sure how big timeout would have to be to prevent this happening and I suspect a small timeout of 0.01 would be enough to allow the while loop to be entered at least once.

https://github.com/eficode/robotframework-imagehorizonlibrary/blob/master/src/ImageHorizonLibrary/recognition/_recognize_images.py#L247

Is it likely to consider improving the stability of the library?

Maybe robotframework-SikuliLibrary is a good reference when it comes to a rich set of keywords and easy usage, which can be confirmed from the following URL:
https://github.com/rainmanwy/robotframework-SikuliLibrary

But robotframework-SikuliLibrary cannot identify the same images that are taken from ONE certain object but through different devices with different video cards. For example, a software logo will be displayed in a different size on different screens or different mobile phones and in such specific cases, robotframework-SikuliLibrary will fail to find the specified image, causing tests that actually already passed to get failed. This issue has a great negative impact on the practical application of similar libraries.

The above issue can be resolved with the help of OpenCV4Python and I hope to see the achievement of robotframework-imagehorizonlibrary in this aspect.

can't integrate to Red...

I installed the lib using python -m pip install robotframework-imagehorizonlibrary
when I do a python -m pip freeze I get : robotframework-imagehorizonlibrary==1.0

now I created a resource file,
image

in red.xml file, it says it can't process the lib keyword because library specification was not generated
image


>python -m robot.libdoc ImageHorizonLibrary ImageHorizonLibrary.libspec
Initializing test library 'ImageHorizonLibrary' with no arguments failed: NameError: global name 'ModuleNotFoundError' is not defined
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\ImageHorizonLibrary\__init__.py", line 149, in __init__
    self.has_cv = utils.has_cv()
  File "C:\Python27\lib\site-packages\ImageHorizonLibrary\utils.py", line 35, in has_cv
    except ModuleNotFoundError as err:

Try --help for usage information.

Problem trying to execute atests

I tried to execute atest windows_tests.robot, but I keep getting

[ ERROR ] Error in file 'C:\Users\User\Desktop\robotframework-imagehorizonlibrary\tests\atest\windows_tests.robot': Importing test library 'ImageHorizo nLibrary' failed: SyntaxError: 'return' with argument inside generator (init.py, line 168) Traceback (most recent call last): File "c:\python27\lib\site-packages\ImageHorizonLibrary_init_.py", line 8, in import pyautogui as ag File "c:\python27\lib\site-packages\pyautogui_init_.py", line 84, in import pyscreeze PYTHONPATH:

ImageNotFoundException on MacOS (but image is on screen)

Just installed the library and giving it a go on MacOS 10.12
Using the keyword Click Image, I get an ImageNotFoundException
Image is clearly on the screen.
The thing is I am getting the same result when the reference image is not even present in the image folder (when I manually place it somewhere else) or name it wrong in the robot script
Am I missing something ?
Thank You

Capability to set the recognition to less than pixel perfect

We are currently facing a problem where we have windows server and windows 8 machine. Setting the windows machine to classic mode leaves the RGB values around 1-2% off which means the picture won't be recognized.

Solution would be to be able to give parameter like check with 90% detail etc.

Error with "Copy From The Right Of"

I am getting error:
Keyword 'ImageHorizonLibrary.Copy From The Right Of' expected 2 arguments, got 3.

This is the code

@{coordinates}= Create List ${150}  ${3}
ImageHorizonLibrary.Copy From The Right Of  LastCmdLable    @{coordinates}

same code is working for
ImageHorizonLibrary.Click To The Right Of Image LastCmdLable @{coordinates}

Thanks

WindowsError: [Error 2] The system cannot find the file specified.

Robot Framework 3.0 (Python 2.7.11 on win32)

When "Click Image" is called, button OK is clicked, but framework logs WindowsError.
I suspect some logging issue....

------------------------------------------------------------------------------
Hit OK                                                                | FAIL |
WindowsError: [Error 2] The system cannot find the file specified.
------------------------------------------------------------------------------

file.robot

*** Settings ***
Library     ImageHorizonLibrary
*** Test Cases ***
Hit OK
    Wait For    ok
    Click Image ok

Able to compare to an image file

Instead of always comparing reference image to a current screenshot, there might also be a need to just compare two arbitrary image files

Text recognition

Capability to define font and text to find the defined box in the screen.

This would remove hassle of changing backgrounds etc.

Probably not the easiest to do, but would be a great addition.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.