user7514606
user7514606

Reputation:

Robot Framework - Focus/Select DropDown popup window

I have a requirement to write a UI test using Robot Framework. I am simulating user login in this website https://www.cosmote.gr/hub/ (select English on the top right of the webpage). User should click on Login/Register and a popup window appears:

popup window

I am trying now to add input text in email text field as well as in password field and then pressing the button to login. Since I am new to Robot Framework, I am not aware how to focus in the popup window and therefore my test are failing - it cannot find the text field in the popup window.

login example

My code is:

    *** Settings ***
Documentation    Present some information about this test suite
Library  Selenium2Library

*** Variables ***
${Browser} =  ff
${HOME_PAGE} =  https://www.cosmote.gr/hub/
${BUTTON_LOGIN} =  //*[@id="wcs_header"]/div[5]/div[1]/div[2]/div/div
${VALID_USERNAME} =  
${VALID_PASSWORD} =  
${PAGE_CONTAINS} =  My COSMOTE
${USERNAME_FIELD} =  //*[@id="loginIn"]
${PASSWORD_FIELD} =  //*[@id="pwdIn"]
${SUBMIT_BUTTON} =  //*[@id="loginBtnIn"]
${POPUP} =  //*[@id="cosid_md_login"]/div[2]
${FRAME} =  idmframeIn

*** Test Cases ***
User Login With Valid Credentials
    [Tags]  Login
    Open Browser  ${HOME_PAGE}  ${Browser}
    Wait Until Element Is Visible  ${BUTTON_LOGIN}
    Click Element  ${BUTTON_LOGIN}
    Wait Until Page Contains  ${PAGE_CONTAINS}
    Select Frame  id=${FRAME}
    Input text  ${USERNAME_FIELD}  ${VALID_USERNAME}
    Input password  ${PASSWORD_FIELD}  ${VALID_PASSWORD}
    Click Element  ${SUBMIT_BUTTON}
    Wait Until Page Contains  Hello
    Close Browser

How can I focus/select the popup window in order to find the text fields and the login button elemenets?

Thanks in advance for your help!

Upvotes: 0

Views: 5674

Answers (1)

A. Kootstra
A. Kootstra

Reputation: 6981

After running your example I noticed that the window is not expanding to maximum size. This may cause the search bar and the link to overlap. When I added the Maximize Browser Window keyword that solved that particular issue.

As the Select Frame was causing issues, and there is no need for it, removed it from the script.

The below script runs and fills in the values. As the username and password are not valid the final check doesn't pass due to a failed login. However, that is expected.

*** Settings ***
Documentation    Present some information about this test suite
Library  Selenium2Library

Suite Teardown    Close All Browsers

*** Variables ***
${Browser} =  chrome
${HOME_PAGE} =  https://www.cosmote.gr/hub/
# ${BUTTON_LOGIN} =  //*[@id="wcs_header"]/div[5]/div[1]/div[2]/div/div
${BUTTON_LOGIN} =  id=cosid_md_login
${VALID_USERNAME} =  dummy
${VALID_PASSWORD} =  dummy
${PAGE_CONTAINS} =  My COSMOTE
${USERNAME_FIELD} =  //*[@id="loginIn"]
${PASSWORD_FIELD} =  //*[@id="pwdIn"]
${SUBMIT_BUTTON} =  //*[@id="loginBtnIn"]
#${FRAME} =  idmframeIn

*** Test Cases ***
User Login With Valid Credentials
    [Tags]  Login
    Open Browser  ${HOME_PAGE}  ${Browser}
    Maximize Browser Window
    Wait Until Element Is Visible  ${BUTTON_LOGIN}
    Click Element  ${BUTTON_LOGIN}
    Wait Until Page Contains  ${PAGE_CONTAINS}
    # Select Frame  id=${FRAME}
    Input Text    ${USERNAME_FIELD}  ${VALID_USERNAME}
    Input password  ${PASSWORD_FIELD}  ${VALID_PASSWORD}
    Click Element  ${SUBMIT_BUTTON}
    Wait Until Page Contains  Hello
    Close Browser

Upvotes: 1

Related Questions