Robot Test
*** Settings ***
Variables test_if_case_sensitive.py
Documentation Suite description
Library Process
*** Variables ***
${pw1} "HeLLo1234"
${pw2} "hello1234"
${test3}
*** Test Cases ***
Test1
${test1}= set variable ${passwordWithCaps}
${test2}= set variable ${passwordWithoutCaps}
${test1}= set variable ${pw1}
${test2}= set variable ${pw2}
${test3}= set variable ${message}
Start Process python3 test_if_case_sensitive.py
Check If It Works
*** Keywords ***
Check If It Works
PASS EXECUTION IF ${test3} == "Passwords do not match"
Here is the python script
#test_if_case_sensitive.py
import socket
import string
import random
global passwordWithCaps
global passwordWithoutCaps
global message
def randomString(stringLength):
"""Generate a random string of fixed length """
letters = string.ascii_lowercase
return ''.join(random.choice(letters) for i in range(stringLength))
def test_check_if_passwords_match_case_sensitive_when_creating_them(passwordWithCaps, passwordWithoutCaps):
username = randomString(random.randint(10, 20))
confirm_password = False
server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
IP_address = "127.0.0.1"
Port = 8081
server.connect((IP_address, Port))
while True:
message = server.recv(2048).decode("utf-8")
if message:
print("Message 1" + message)
if confirm_password:
print("Message 2" + message)
if message.__contains__("You have successfully registered"):
raise Exception("Passwords match when they shouldn't")
break
if message.__contains__("Please enter username"):
server.send("--register".encode())
if message.__contains__("Please enter a username to register"):
server.send(username.encode())
if message.__contains__("Please create a password"):
server.send(passwordWithCaps.encode())
if message.__contains__("Please confirm password"):
confirm_password = True
server.send(passwordWithoutCaps.encode())
print(message)
test_check_if_passwords_match_case_sensitive_when_creating_them(passwordWithCaps, passwordWithoutCaps)
I am trying to assign global variables passwordWithCaps and passwordWithoutCaps from the Robot Test script using variables ${pw1} and ${pw2}. I instead get an error saying 'passwordWithCaps' is not defined which shows the issue stems from the python script. However, I also get this in the Robot Test -
Test1 | FAIL |
Variable '${passwordWithCaps}' not found.