From e3346676c8b381a6ea6f9ddfd30aca7aca65e9a9 Mon Sep 17 00:00:00 2001 From: Alexander Mentyu Date: Sun, 28 Jul 2019 23:28:59 +0300 Subject: [PATCH] Use Unix timestamp instead of randint to insure unique values --- locustfile.py | 3 ++- test_popup_web.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/locustfile.py b/locustfile.py index 59214d6..91170e6 100644 --- a/locustfile.py +++ b/locustfile.py @@ -1,4 +1,5 @@ # from json.decoder import JSONDecodeError +import time from random import randint from locust import HttpLocust, TaskSet, task, runners @@ -14,7 +15,7 @@ def post_user_action(self): if 0 <= user_action <= 6: payload = {"user_action": str(user_action), - "feedback": "Load testing Locust {}".format(randint(0, 999999999999999999))} + "feedback": "Load testing Locust {}".format(time.time())} else: payload = {"user_action": str(user_action), "feedback": ""} diff --git a/test_popup_web.py b/test_popup_web.py index 3d20847..7cc884d 100644 --- a/test_popup_web.py +++ b/test_popup_web.py @@ -21,8 +21,8 @@ def _click_button_input_feedback_click_send_wait(driver, popup_button): popup_button.click() feedback_area = driver.find_element_by_class_name("NPS__feedback-textarea") feedback_area.click() - # Random number possibly will be used for future database auto tests for finding the right fields - feedback_area.send_keys("Testing WebDriver {}".format(randint(0, 999999999999999999))) + # Unix timestamp possibly will be used for future database auto tests for finding the right fields + feedback_area.send_keys("Testing WebDriver {}".format(time.time())) send_button = driver.find_element_by_class_name("NPS__feedback-send") send_button.click() _sleep_time()