lcc_tool/test/pages/assistant.py

46 lines
1.9 KiB
Python

import time
from selenium.webdriver.common.by import By
from conftest import driver
from pages.base_page import BasePage
class Assistant(BasePage):
"""Page Object für den Assistant"""
# Mapping von Excel-Feldnamen zu Locators
FIELD_MAPPING = {
"PART_NUMBER": (By.CSS_SELECTOR, "textarea[name='partNumbers']"),
"ANALYZE_BUTTON": (By.CSS_SELECTOR, ".part-number-modal-action > .btn--primary"),
"SUPPLIER_NAME": (By.CSS_SELECTOR, ".supplier-headers-searchbar-container .search-input"),
"LOAD_FROM_PREVIOUS": (By.CSS_SELECTOR, ".start-calculation-footer-container .checkbox-item"),
"CREATE_CALCULATION_BUTTON": (By.CSS_SELECTOR, ".start-calculation-footer-container .btn--secondary"),
"DELETE_SUPPLIER_BUTTON": (By.CSS_SELECTOR, ".supplier-headers ~ .item-list .item-list-element .icon-btn-container .icon-btn"),
}
def search_part_numbers(self, data_dict):
"""Füllt das Formular mit Daten aus dem Excel"""
self.fill_input(*self.FIELD_MAPPING["PART_NUMBER"], data_dict["PART_NUMBER"])
self.click_button(*self.FIELD_MAPPING["ANALYZE_BUTTON"])
def delete_preselected_suppliers(self):
while True:
try:
button = self.wait_for_clickable(
*self.FIELD_MAPPING["DELETE_SUPPLIER_BUTTON"],
timeout=1
)
button.click()
time.sleep(0.2)
except:
# Keine Buttons mehr vorhanden
break
def select_supplier(self, data_dict):
self.search_and_select_autosuggest(*self.FIELD_MAPPING["SUPPLIER_NAME"], data_dict["SUPPLIER_NAME"])
def create_calculation(self, data_dict):
self.set_checkbox(*self.FIELD_MAPPING["LOAD_FROM_PREVIOUS"], data_dict["LOAD_FROM_PREVIOUS"])
self.click_button(*self.FIELD_MAPPING["CREATE_CALCULATION_BUTTON"])