from selenium.webdriver.common.by import By
from src.testproject.classes import DriverStepSettings, StepSettings
from src.testproject.decorator import report_assertion_errors
from src.testproject.enums import SleepTimingType
from src.testproject.sdk.drivers import webdriver
import pytest


"""
This pytest test was automatically generated by TestProject
    Project: My first Project
    Package: TestProject.Generated.Tests.MyFirstProject
    Test: Eliminar producto
    Generated by: Fabio Blanco (fablanco45@ucatolica.edu.co)
    Generated on 10/14/2021, 00:04:18
"""


@pytest.fixture()
def driver():
    driver = webdriver.Chrome(token="9YMUsLk66WOGc3Dz5dL5rH53KY99wF1zvatoBn7Lxzs",
                              project_name="My first Project",
                              job_name="Eliminar producto")
    step_settings = StepSettings(timeout=15000,
                                 sleep_time=500,
                                 sleep_timing_type=SleepTimingType.Before)
    with DriverStepSettings(driver, step_settings):
        yield driver
    driver.quit()


@report_assertion_errors
def test_main(driver):
    # Test Parameters
    # Auto generated application URL parameter
    ApplicationURL = "http://localhost:8100/home"

    # 1. Navigate to '{ApplicationURL}'
    # Navigates the specified URL (Auto-generated)
    driver.get(f'{ApplicationURL}')

    # 2. Click 'Balón de Futbol'
    bal_n_de_futbol = driver.find_element(By.XPATH,
                                          "//ion-card-title[. = 'Balón de Futbol']")
    bal_n_de_futbol.click()

    # 3. Click 'ELIMINAR'
    eliminar = driver.find_element(By.XPATH,
                                   "//ion-button[. = 'Eliminar']")
    eliminar.click()
