Skip to content

Commit

Permalink
py tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kb-kerem committed May 21, 2024
1 parent 574fdaf commit 6fa555f
Show file tree
Hide file tree
Showing 7 changed files with 119 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/env-vars-custom-id.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BuildMode, BuildStatus, SauceRegion, getApi } from '@saucelabs/visual';
import { BuildStatus, SauceRegion, getApi } from '@saucelabs/visual';
import {
RE_VISUAL_BUILD_ID,
RE_VISUAL_BUILD_LINK,
Expand Down
5 changes: 5 additions & 0 deletions visual-python/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,8 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
*.iml

# test results
log.html
output.xml
report.html
9 changes: 9 additions & 0 deletions visual-python/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.12-slim-bookworm

COPY . .

RUN pip install -r requirements/dev.txt

RUN pip install .

ENTRYPOINT ["robot", "integration-tests/login"]
12 changes: 12 additions & 0 deletions visual-python/integration-tests/login/__init__.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
*** Settings ***
Resource resource.robot
Suite Setup Setup
Suite Teardown Teardown

*** Keywords ***
Setup
Create Visual Build

Teardown
Finish Visual Build
Visual Build Status
2 changes: 2 additions & 0 deletions visual-python/integration-tests/login/resource.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*** Settings ***
Library saucelabs_visual.frameworks.robot.SauceLabsVisual
26 changes: 26 additions & 0 deletions visual-python/integration-tests/login/tests/login.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*** Settings ***
Documentation A test suite with a single test for valid login.
...
... This test has a workflow that is created using keywords in
... the imported resource file.
Resource resource.robot
Suite Setup Open Browser browser=${BROWSER} remote_url=${REMOTE URL} options=set_capability('sauce:options', ${DESIRED CAPABILITIES})
Suite Teardown Close Browser

*** Test Cases ***
Valid Login
Open Browser To Login Page
${username} = Setup User
Input Username ${username}
Input Password secret_sauce
Submit Credentials
Welcome Page Should Be Open
Visual Snapshot Valid Login capture_dom=True

Invalid Login
Open Browser To Login Page
Input Username locked_out_user
Input Password secret_sauce
Submit Credentials
Login Page Should Be Open
Visual Snapshot Invalid Login capture_dom=True
64 changes: 64 additions & 0 deletions visual-python/integration-tests/login/tests/resource.robot
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
*** Settings ***
Documentation A resource file with reusable keywords and variables.
...
... The system specific keywords created here form our own
... domain specific language. They utilize keywords provided
... by the imported SeleniumLibrary.
Library SeleniumLibrary
Library saucelabs_visual.frameworks.robot.SauceLabsVisual

*** Variables ***
${BROWSER} Chrome
${DELAY} 0
${LOGIN URL} https://www.saucedemo.com/
${INVENTORY PAGE} https://www.saucedemo.com/inventory.html
# NOTE: If using an ondemand Sauce region other than us-west-1, you need to supply the matching
# region to the `SAUCE_REGION` ENV before visual build creation to have it utilize the same
# datacenter.
# Ex:
# REMOTE URL=https://ondemand.eu-central-1.saucelabs.com/wd/hub
# SAUCE_REGION=eu-central-1
${REMOTE URL} https://ondemand.us-west-1.saucelabs.com:443/wd/hub
${DESIRED CAPABILITIES} {"username": "%{SAUCE_USERNAME}", "accessKey": "%{SAUCE_ACCESS_KEY}", "sauce:options": {"browser_version": "latest", "platform_name": "Windows 11", "browser": "chrome"}}

*** Keywords ***
Open Browser To Login Page
Go To ${LOGIN URL}
Maximize Browser Window
Set Selenium Speed ${DELAY}
Login Page Should Be Open

Login Page Should Be Open
Location Should Be ${LOGIN URL}
Title Should Be Swag Labs

Go To Login Page
Go To ${LOGIN URL}
Login Page Should Be Open

Input Username
[Arguments] ${username}
Input Text user-name ${username}

Input Password
[Arguments] ${password}
Input Text password ${password}

Submit Credentials
Click Button login-button

Welcome Page Should Be Open
Location Should Be ${INVENTORY PAGE}
Title Should Be Swag Labs

Setup User
TRY
IF "%{VISUAL_CHECK}" == "1"
VAR ${username} visual_user
ELSE
VAR ${username} standard_user
END
EXCEPT
VAR ${username} standard_user
END
RETURN ${username}

0 comments on commit 6fa555f

Please sign in to comment.