Initial commit - Selenium automation framework
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from selenium.webdriver.common.by import By
|
||||
from selenium.webdriver.support.ui import WebDriverWait
|
||||
import pytest
|
||||
|
||||
from tests.step_actions import StepActions
|
||||
from tests.helpers import login, select_ui_dropdown
|
||||
from tests.config_reader import is_combined_setup_enabled, is_setup_session_enabled, load_config
|
||||
from tests.locators import Locator
|
||||
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
is_combined_setup_enabled() or not is_setup_session_enabled(),
|
||||
reason="Standalone session setup is disabled or runs inside combined setup",
|
||||
)
|
||||
|
||||
|
||||
def get_session_window(config):
|
||||
|
||||
session_config = config.get("setup", {}).get("session", {})
|
||||
start_offset_minutes = session_config.get("start_offset_minutes", 7)
|
||||
end_time = session_config.get("end_time", "20:30")
|
||||
|
||||
start_datetime = datetime.now() + timedelta(minutes=start_offset_minutes)
|
||||
today = datetime.now().strftime("%d/%m/%Y")
|
||||
|
||||
return start_datetime.strftime("%d/%m/%Y %H:%M"), f"{today} {end_time}"
|
||||
|
||||
|
||||
def create_session(driver, step, config):
|
||||
|
||||
step.click((By.XPATH, Locator.tradingmaintenance), "trading_maintenance")
|
||||
|
||||
step.click((By.XPATH, Locator.tradingsession), "trading_session")
|
||||
|
||||
step.click((By.XPATH, Locator.addsessionbtn), "add_session")
|
||||
|
||||
select_ui_dropdown(driver, "meInstanceId", config["product"]["me_instance"])
|
||||
|
||||
step.capture("select_product")
|
||||
|
||||
start_date_time, end_date_time = get_session_window(config)
|
||||
|
||||
step.type((By.XPATH, Locator.inputstartdate), start_date_time, "start_date")
|
||||
|
||||
step.type((By.XPATH, Locator.inputenddate), end_date_time, "end_date")
|
||||
|
||||
step.click((By.XPATH, Locator.sessionsavebtn), "save_session")
|
||||
|
||||
|
||||
@pytest.mark.session
|
||||
def test_session(driver, test_context):
|
||||
|
||||
config = load_config()
|
||||
|
||||
wait = WebDriverWait(driver, 20)
|
||||
|
||||
step = StepActions(driver, wait, test_context)
|
||||
|
||||
driver.get(config["url"])
|
||||
step.capture("open_application")
|
||||
|
||||
login(
|
||||
driver,
|
||||
config["login"]["username"],
|
||||
config["login"]["password"]
|
||||
)
|
||||
|
||||
step.capture("login")
|
||||
|
||||
create_session(driver, step, config)
|
||||
Reference in New Issue
Block a user