Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Don't throw an error if RobotEyes isn't actually used in a test case, but still imported in ***Settings*** #74

Closed
janringas opened this issue Sep 7, 2020 · 1 comment

Comments

@janringas
Copy link

Is your feature request related to a problem? Please describe.
I'm having an issue when I don't use RobotEyes in one of my tests.
Because I globally import it in a resource file (and use it in some cases, but not in others) I can't import it only in those cases I actually need a keyword using RobotEyes.
In this "problematic use case" the instance (is that the correct wording?) of the RobotEyes library has no attribute 'lib', because Open Eyes hasn't been called (and the test designer of the test cases maybe even doesn't know of that library in the resource file), causing the test to fail with the following message:
[ ERROR ] Calling method '_end_test' of listener 'RobotEyes' failed: AttributeError: 'RobotEyes' object has no attribute 'lib'

A (simple example) test I'm running to reproduce the error message is (here I import the library directly instead of using a resource file):

*** Settings ***
Documentation    123
Library    RobotEyes
Library    SeleniumLibrary

*** Variables ***
${blur}    xpath=//*[@id="tsf"]/div[2]/div[1]/div[3]/center/input[1]

*** Test Cases ***
Open Browser
    Open Browser    https://www.google.com    gc
#   Open Eyes
    Capture Page Screenshot    filename=Test123.png
#   Capture Full Screen    tolerance=85  blur=${blur}  radius=5
    Close Browser
#   Compare Images

Describe the solution you'd like
A solution I tested locally and which seemed to work was the following (I edited _end_test to first check if there actually is an attribute 'lib' before doing anything):

    def _end_test(self, data, test):
        if hasattr(self, 'lib'):
            if self.lib.lower() == 'none':
                if self.fail:
                    test.status = 'FAIL'
                    test.message = 'Image dissimilarity exceeds tolerance'

Describe alternatives you've considered
An alternative (working in our context) was to manually set 'self.lib' to 'SeleniumLibrary' (which is the web library we are using), but this didn't seem as good to me compared to adding the check to _end_test.

Additional context
As we are using Robot Framework distributed across multiple machines having the proposed (or a similar) fix/workaround in the library would help us greatly because we wouldn't need to change the file on all machines manually.

@janringas janringas changed the title Don't throw an error if RobotEyes isn't actually used Don't throw an error if RobotEyes isn't actually used in a test case, but still imported in ***Settings*** Sep 7, 2020
@jessezach
Copy link
Owner

Fix released in 1.5.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants