Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 41 additions & 19 deletions RobotAppEyes/RobotAppEyes.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,17 @@ class RobotAppEyes:
"""
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
ROBOT_LIBRARY_VERSION = VERSION
BatchDic=dict()

def _eyes_set_batch(self,batchName,ApplitoolsJenkinsPlugin):
batch = BatchInfo(batchName)
if ApplitoolsJenkinsPlugin is True:
batch.id = os.environ['APPLITOOLS_BATCH_ID']
if batchName is None:
batch.name = os.environ['JOB_NAME']
if batchName not in self.BatchDic.keys():
self.BatchDic[batchName]=batch
eyes.batch=self.BatchDic[batchName]

def open_eyes_session(self,
appname,
Expand All @@ -86,24 +97,31 @@ def open_eyes_session(self,
httpDebugLog=False,
baselineName=None,
batchName=None,
ApplitoolsJenkinsPlugin=False,
branchname=None,
parentbranch=None):
parentbranch=None,
hideScrollBar=False,
fullPageScreenshot=False,
matchTimeout=None):
"""
Starts a session with the Applitools Eyes Website.

Arguments:
| Application Name (string) | The name of the application under test. |
| Test Name (string) | The test name. |
| API Key (string) | User's Applitools Eyes key. |
| (Optional) Width (int) | The width of the browser window e.g. 1280 |
| (Optional) Height (int) | The height of the browser window e.g. 1000 |
| (Optional) Operating System (string) | The operating system of the test, can be used to override the OS name to allow cross OS verfication |
| (Optional) Browser Name (string) | The browser name for the test, can be used to override the browser name to allow cross browser verfication |
| (Optional) Match Level (string) | The match level for the comparison - can be STRICT, LAYOUT or CONTENT |
| Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable. |
| HTTP Debug Log (default=False) | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. |
| Branch Name (default=False) | The branch to use to check test |
| Parent Branch (default=False) | Parent Branch to base the new Branch on |
| Application Name (string) | The name of the application under test. |
| Test Name (string) | The test name. |
| API Key (string) | User's Applitools Eyes key. |
| (Optional) Width (int) | The width of the browser window e.g. 1280 |
| (Optional) Height (int) | The height of the browser window e.g. 1000 |
| (Optional) Operating System (string) | The operating system of the test, can be used to override the OS name to allow cross OS verfication |
| (Optional) Browser Name (string) | The browser name for the test, can be used to override the browser name to allow cross browser verfication |
| (Optional) Match Level (string) | The match level for the comparison - can be STRICT, LAYOUT or CONTENT |
| Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable. |
| HTTP Debug Log (default=False) | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. |
| (Optional) Branch Name (default=None) | The branch to use to check test | For further information - http://support.applitools.com/customer/portal/articles/2142886
| (Optional)Parent Branch (default=None) | Parent Branch to base the new Branch on | For further information - http://support.applitools.com/customer/portal/articles/2142886
| (Optional) fullPageScrennshot (default=False) | Will force the browser to take a screenshot of whole page. |
| (Optional) matchTimeout | The amount of time that Eyes will wait for an image to stabilize to a point that it is similar to the baseline image | For further information - http://support.applitools.com/customer/portal/articles/2099488
| (Optional) ApplitoolsJenkinsPlugin (Boolean) | Integration with Applitools Jenkins Plugin | For further information - http://support.applitools.com/customer/portal/articles/2689601

Creates an instance of the Selenium2Library webdriver.
Defines a global driver and sets the Selenium2Library webdriver to the global driver.
Expand All @@ -129,6 +147,12 @@ def open_eyes_session(self,
global eyes
eyes = Eyes()
eyes.api_key = apikey
self._eyes_set_batch(batchName,ApplitoolsJenkinsPlugin)
eyes.force_full_page_screenshot = fullPageScreenshot
eyes.hide_scrollbars = hideScrollBar
if baselineName is not None:
eyes.baseline_name = baselineName # (str)

s2l = BuiltIn().get_library_instance('Selenium2Library')
webdriver = s2l._current_browser()
driver = webdriver
Expand All @@ -142,11 +166,10 @@ def open_eyes_session(self,
eyes.host_os = osname # (str)
if browsername is not None:
eyes.host_app = browsername # (str)
if matchTimeout is not None:
eyes._match_timeout= int(matchTimeout)
if baselineName is not None:
eyes.baseline_name = baselineName # (str)
if batchName is not None:
batch =BatchInfo(batchName)
eyes.batch = batch
if matchlevel is not None:
eyes.match_level = matchlevel
if parentbranch is not None:
Expand All @@ -161,15 +184,15 @@ def open_eyes_session(self,
eyes.open(driver, appname, testname, {'width': intwidth, 'height': intheight})


def check_eyes_window(self, name, force_full_page_screenshot=False,

def check_eyes_window(self, name,
includeEyesLog=False, httpDebugLog=False):
"""
Takes a snapshot from the browser using the web driver and matches it with
the expected output.

Arguments:
| Name (string) | Name that will be given to region in Eyes. |
| Force Full Page Screenshot (default=False) | Will force the browser to take a screenshot of whole page. |
| Include Eyes Log (default=False) | The Eyes logs will not be included by default. To activate, pass 'True' in the variable. |
| HTTP Debug Log (default=False) | The HTTP Debug logs will not be included by default. To activate, pass 'True' in the variable. |

Expand All @@ -188,7 +211,6 @@ def check_eyes_window(self, name, force_full_page_screenshot=False,
if httpDebugLog is True:
httplib.HTTPConnection.debuglevel = 1

eyes.force_full_page_screenshot = force_full_page_screenshot
eyes.check_window(name)

def check_eyes_region(self, element, width, height, name, includeEyesLog=False, httpDebugLog=False):
Expand Down
53 changes: 53 additions & 0 deletions Tests/acceptance/DemoTest.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
*** Settings ***
Library Selenium2Library
Library RobotAppEyes

*** Variables ***
### Selenium2Library Variables ###
${Timeout} 15

### Css Variables ###
${Features} css=.features>a

### Applitools Variables ###
${Applitools-url} https://www.applitools.com/
${Applitools-AppName} MyAppName
${Applitools-TestName} MyTestName
${Applitools-Key} YOUR_API_KEY
${Width} 1000
${Height} 800
${MatchLevel} LAYOUT2
${True} True
${False} False
${firstBatchName} MyBatchName
${secondBatchName} MyBatchName2
${matchTimeout} 3000

*** Test Cases ***

Test1
[Documentation]
Open Browser ${Applitools-url} Chrome
Open Eyes Session appname=${Applitools-AppName} testname=${Applitools-TestName} apikey=${Applitools-Key} width=${Width} height=${Height} matchlevel=${MatchLevel} batchName=${firstBatchName} fullPageScreenshot=${False} hideScrollBar=${True} matchTimeout=${matchTimeout}
Check Eyes Window Main Page New
Close Browser
Close Eyes Session


Test2
[Documentation]
Open Browser ${Applitools-url} Chrome
Open Eyes Session appname=${Applitools-AppName} testname=${Applitools-TestName} apikey=${Applitools-Key} width=${Width} height=${Height} matchlevel=${MatchLevel} fullPageScreenshot=${False} hideScrollBar=${True} batchName=${secondBatchName} matchTimeout=${matchTimeout}
Check Eyes Window Main Page New
Close Browser
Close Eyes Session



Test3
[Documentation]
Open Browser ${Applitools-url} Chrome
Open Eyes Session appname=${Applitools-AppName} testname=${Applitools-TestName} apikey=${Applitools-Key} width=${Width} height=${Height} matchlevel=${MatchLevel} fullPageScreenshot=${False} hideScrollBar=${True} batchName=${firstBatchName} matchTimeout=${matchTimeout}
Check Eyes Window Main Page New
Close Browser
Close Eyes Session
33 changes: 33 additions & 0 deletions Tests/acceptance/DemoTestJenkinsPlugin.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
*** Settings ***
Library Selenium2Library
Library RobotAppEyes

*** Variables ***
### Selenium2Library Variables ###
${Timeout} 15

### Css Variables ###
${Features} css=.features>a

### Applitools Variables ###
${Applitools-url} https://www.applitools.com/
${Applitools-AppName} MyAppName
${Applitools-TestName} MyTestName
${Applitools-Key} YOUR_API_KEY
${Width} 1000
${Height} 800
${MatchLevel} LAYOUT2
${True} True
${False} False
${firstBatchName} MyBatchName
${matchTimeout} 3000

*** Test Cases ***

Test1
[Documentation]
Open Browser ${Applitools-url} Chrome
Open Eyes Session appname=${Applitools-AppName} testname=${Applitools-TestName} apikey=${Applitools-Key} width=${Width} height=${Height} matchlevel=${MatchLevel} batchName=${firstBatchName} ApplitoolsJenkinsPlugin=${True} fullPageScreenshot=${False} hideScrollBar=${True} matchTimeout=${matchTimeout}
Check Eyes Window Main Page New
Close Browser
Close Eyes Session
Loading