*** Settings ***
Library    SeleniumLibrary

*** Variables ***
${PAGE_LOGIN_HEADER_LOCATOR}=    css=h1
${EMAIL_TEXTBOX_LOCATOR}=    id=email
${PASSWORD_TEXTBOX_LOCATOR}=   id=password 
${LOGIN_BUTTON_LOCATOR}=    xpath=//*[@id="root"]/div/div/div/div/form/div[2]/button  
${CREATE_ACCOUNT_LINK_LOCATOR}=    xpath=//*[@id="root"]/div/div/div/div/div[3]/a
${FORGOT_PASSWORD_LINK_LOCATOR}=    id=forgotPasswordLink
${MESSAGE_ALERTE_INCORRECT_LOGIN_LOCATOR}=    xpath=//*[@id="root"]/div/div/div/div/div[1]/div/div/div

*** Keywords ***
Vérifier l'affichage de la page "Login"
    ${Page_login_header_text}=    Get Text    ${PAGE_LOGIN_HEADER_LOCATOR}
    Should Be Equal As Strings    ${Page_login_header_text}    Login    ignore_case=true 

Remplir le formulaire de login
    [Arguments]    @{Donnees_Login}
    Input Text    ${EMAIL_TEXTBOX_LOCATOR}    ${Donnees_Login}[0]
    Input Text    ${PASSWORD_TEXTBOX_LOCATOR}    ${Donnees_Login}[1]

Soumettre le formulaire de Login
    Click Button    ${LOGIN_BUTTON_LOCATOR}

Cliquer sur le lien "Create a free account"
    Click Element    ${CREATE_ACCOUNT_LINK_LOCATOR}

Cliquer sur le lien "Forgot Password"
    Click Element    ${FORGOT_PASSWORD_LINK_LOCATOR}

    
Vérifier Login KO 
    ${Current_Page_Url}=    Get Location
    Should Be Equal As Strings    ${Current_Page_Url}    https://practice.expandtesting.com/notes/app/login
    Wait Until Element Is Visible    ${MESSAGE_ALERTE_INCORRECT_LOGIN_LOCATOR}
    ${Text_message_alerte}=    Get Text    ${MESSAGE_ALERTE_INCORRECT_LOGIN_LOCATOR}
    Should Be Equal As Strings     ${Text_message_alerte}    Incorrect email address or password    ignorecase=true