collective / robotframework-selenium2screenshots

Robot Framework keyword library for capturing annotated screenshots with Selenium2Library
28 stars 12 forks source link

Javascript exception when executing Capture and Crop Page Screenshot with multiple locators #12

Closed ghost closed 6 years ago

ghost commented 6 years ago

Situation

I want to create a screenshot of the bounding box that covers two elements. I'm using Python 2.7 and Selenium2Screenshots 0.8.0, and create the screenshots in Firefox. When I execute the keyword, I get a JavaScript exception:

JavascriptException: Message: SyntaxError: missing ] after element list

I have tried to use CSS selectors and XPaths as the locators, and both produce the same error. I created a simple testcase which produces the same error:

*** Settings ***
Library           Selenium2Library
Resource          ../../../../../Python27/Lib/site-packages/robotframework_selenium2screenshots-0.8.0-py2.7.egg/Selenium2Screenshots/keywords.robot

*** Test Cases ***
Test
    Open Browser    http://www.google.com    ff
    Capture and crop page screenshot    Google.png    css=#hplogo    css=#lst-ib    # Crop to include the Google logo and search bar only.
    Close Browser
datakurre commented 6 years ago

@Meilindis Thank you for your report. Would you have any other example than Google? I'm unable to reproduce the issue with the version of their homepage I get.

Does it make difference to add keyword call

Bootstrap jQuery

before Capture and crop page screenshot?

datakurre commented 6 years ago

As a reference, an example that seems to work:

*** Test Cases ***
Test
    Open Browser  https://www.seleniumhq.org/  browser=headlessfirefox
    Capture and crop page screenshot  menubuttons.png  css=#menu_about  css=#menu_support
    Close Browser

So, possibly there is a corner case that causes errors. Reproducible example could help here.

datakurre commented 6 years ago

@Meilindis I'm sorry about my earlier comment. Me unable to properly run the given example was due to my setup. The example run without errors and reproduced the following image for me with headlessfirefox (supported by the latest seleniumlibrary).

Test
    Open Browser  https://www.google.com/  browser=headlessfirefox
    Bootstrap jQuery
    Capture and crop page screenshot    Google.png    css=#hplogo    css=#lst-ib    # Crop to include the Google logo and search bar only.
    Close Browser

google

ghost commented 6 years ago

Thank you for your quick reply!

I have tried adding Bootstrap jQuery, but it did not make a difference. I'm using Firefox Developer edition, by the way.

I guess it may have to do with my setup somehow, if it works for you. I'll attach the log of the simple test, perhaps you can see what goes wrong. log.zip

datakurre commented 6 years ago

@Meilindis Thank you. The log revealed a real issue. I cannot fix this today, but hopefully this week.

A workaround is to use Python 3 if possible.

ghost commented 6 years ago

@datakurre Thank you very much! I will use Python 3 for now, then.

I really appreciate your efforts to make this library available to us!

ghost commented 6 years ago

@datakurre Do you have an estimate when this issue will be fixed? Thank you!

datakurre commented 6 years ago

@Meilindis Thank you for reminding. This should be now fixed in https://pypi.python.org/pypi/robotframework-selenium2screenshots/0.8.1

If not, please, reopen the issue.

ghost commented 6 years ago

@datakurre Thank you, it is working now!