From c296d90b02f39dff1487d6cf26b21add1a519eca Mon Sep 17 00:00:00 2001 From: Joona Oikarinen Date: Tue, 4 Jan 2022 16:29:06 +0200 Subject: [PATCH 1/2] feat: add timeout for start of SUT Add possibility to define timeout for SUT in ini file. --- change_analyzer/main.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/change_analyzer/main.py b/change_analyzer/main.py index 40b2b05..0ca4087 100644 --- a/change_analyzer/main.py +++ b/change_analyzer/main.py @@ -1,5 +1,5 @@ +import configparser import uuid -from configparser import ConfigParser from datetime import datetime import argparse @@ -14,7 +14,7 @@ from change_analyzer.wrappers.sequence_recorder import SequenceRecorder -CONFIG = ConfigParser() +CONFIG = configparser.ConfigParser() def reset() -> WebDriver: @@ -26,6 +26,12 @@ def reset() -> WebDriver: "deviceName": "WindowsPC", } driver = webdriver.Remote(CONFIG["driver"]["command_executor"], capabilities) + try: + timeout = CONFIG.get("driver", "timeout") + print(f"{timeout} second timeout defined.") + driver.implicitly_wait(timeout) + except configparser.NoOptionError: + print("No timeout defined.") if CONFIG["driver"]["platform"] == "web": web_options = webdriver.ChromeOptions() From d68154917078524a222d48a01e8c0f04b7d42d10 Mon Sep 17 00:00:00 2001 From: Joona Oikarinen Date: Tue, 4 Jan 2022 17:05:26 +0200 Subject: [PATCH 2/2] chore: make code cleaner Make try expect logic cleaner --- change_analyzer/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/change_analyzer/main.py b/change_analyzer/main.py index 0ca4087..c962606 100644 --- a/change_analyzer/main.py +++ b/change_analyzer/main.py @@ -1,5 +1,5 @@ -import configparser import uuid +from configparser import ConfigParser, NoOptionError from datetime import datetime import argparse @@ -14,7 +14,7 @@ from change_analyzer.wrappers.sequence_recorder import SequenceRecorder -CONFIG = configparser.ConfigParser() +CONFIG = ConfigParser() def reset() -> WebDriver: @@ -28,10 +28,10 @@ def reset() -> WebDriver: driver = webdriver.Remote(CONFIG["driver"]["command_executor"], capabilities) try: timeout = CONFIG.get("driver", "timeout") - print(f"{timeout} second timeout defined.") - driver.implicitly_wait(timeout) - except configparser.NoOptionError: - print("No timeout defined.") + except NoOptionError: + timeout = 0 + print(f"Current timeout:{timeout} seconds") + driver.implicitly_wait(timeout) if CONFIG["driver"]["platform"] == "web": web_options = webdriver.ChromeOptions()