from allure import step from playwright.sync_api import expect from src.ui_elements.base_ui_element import BaseUIElement class DropDownUIElement(BaseUIElement): @step('Select {option} option from {0}') def select_option(self, option, choice_locator): self._element.click() choice = self.page.locator('{}//*[text()="{}"]'.format(self.locator, option)) choice.click() self.verify_chosen(option) @step('Verify chosen option is {option} from {0}') def verify_chosen(self, option): expect(self._element.locator("xpath=/span[string-length(.) > 0]")).to_have_text(option) def __str__(self): return f"DropDown {self.name}"