from selenium.webdriver.common.by import By

class KmartLoginPage:
    LOGIN_URL = 'https://www.kmart.com.au/webapp/wcs/stores/servlet/LogonForm?catalogId=10102&myAcctMain=1&langId=-1&storeId=10701'

    LOGIN_ID = (By.NAME, 'logonId')
    PASSWORD_ID = (By.NAME, 'logonPassword')
    LOGIN_BUTTON_ID = (By.ID, 'WC_AccountDisplay_links_2')

    def __init__(self, browser):
        self.browser = browser

    def load(self):
        self.browser.get(self.LOGIN_URL)

    def login(self, username, password):
        search_input = self.browser.find_element(*self.LOGIN_ID)
        search_input.send_keys(username)

        search_input = self.browser.find_element(*self.PASSWORD_ID)
        search_input.send_keys(password)

        self.browser.find_element(*self.LOGIN_BUTTON_ID).click()
