0
votes

I have a Robot Framework test which uses Selenium2Library to work with a web-based user interface. I fill out and submit a form which contains just 4 textarea. Submitted data will be shown in a table under the form and whenever I click on a row, its data will be exported to the form for editing. I use this feature to confirm data submission. But when I click on the row and the data is exported to the form, Robot Framework cant find text-boxes except the first one, even though the source of the page shows that all of them are located in the HTML content. This is part of my code which is trying to check contents of text-areas:

run keyword     textfield value should be   id=${sponsorName}   ${name}     Sponsor name does not match the expected one: ${name}
run keyword if  '${contactInfo}' != '${EMPTY}'  textfield value should be   id=${sponsorContactInfo}    ${contactInfo}  Sponsor Contact Information does not match the expected one: ${contactInfo}
run keyword if  '${description}' != '${EMPTY}'  textfield value should be   id=${sponsorDescription}    ${description}  Sponsor Description does not match the expected one: ${description}
run keyword if  '${email}' != '${EMPTY}'        textfield value should be   id=${sponsorEmail}          ${email}        Sponsor Email does not match the expected one: ${email}

Method textfield value should be returns False. I put a break-point into this method to check what is the actual source of the problem and it turned out that the library cant find the element to check its content.

1
Are you sure element is visible? Sometimes, especially in one page web applications, elements appear after a while. Have you tried putting "Wait Until Page Contains Element id=${sponsorDescription}" in front of textfield checks? - Pekka
@Pekka, ye I did and the library return timeout error! :-| - Zeinab Abbasimazar
Add the original HTML code? It may help. - Yu Zhang
@YuZhang, I'm sorry; I can't publish HTML for security reasons. - Zeinab Abbasimazar

1 Answers

1
votes

Finally I decided to write my own keyword:

Input Text Should Be
    [Arguments]     ${locator}      ${expectedValue}        ${errorMessage}
    ${text} =       get value       id=${locator}
    log to console      TextBox: ${text}, expected: ${expectedValue}
    run keyword if      '${expectedValue}' != '${text}'     Fail    ${errorMessage}