Reading value from a disabled field

1,165 views
Skip to first unread message

Ludovic

unread,
Apr 4, 2018, 9:59:29 AM4/4/18
to robotframework-users
Hi there

I am trying to read the value of a disabled field but the answer remains the same (Element Should Contain) :
Element 'xpath=//*[@id='site-client-charge-gestion']' should have contained text '4' but its text was ''.

So Robot Framework is not able to read this value. I tried also "Page Should Contain" but it still doesn't find it in the page.

Do you know how to do to get this value? It is supposed to be equal to 4. It seems that it is possible to use Javascript but I have no idea how to use it.

Thanks

Ludovic

unread,
Apr 4, 2018, 10:42:44 AM4/4/18
to robotframework-users
I finally managed to do it. Problem solved

Benjamin H

unread,
Apr 4, 2018, 11:26:44 AM4/4/18
to robotframework-users
This is common problem in forum posts, but could you explain how you solved it? It may even be super simple, but for the record it's always good to post the solution. Who knows how many people you may save a hassle in the future?

Dmitriy

unread,
Apr 4, 2018, 11:31:33 AM4/4/18
to toukunpr...@gmail.com, robotframework-users
I guess here answer covers in his question. He tries to verify value of disabled input. So it is value not text.
So you need to use Get Value or Textfield Value Should Be keywords.


Thanks,
D



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Ludovic

unread,
Apr 5, 2018, 3:23:48 AM4/5/18
to robotframework-users
Hi

There are 3 ways (or more) to do it:

checkValuesDisabledField

    [Arguments]    ${Id_to_check}    ${expected_value}

    ${tempVariable}=    Execute Javascript   return document.getElementById("${Id_to_check}").value

    Should Be Equal   ${expected_value}     ${tempVariable}

 

checkValuesDisabledField2

    [Arguments]    ${Id_to_check}    ${expected_value}

    ${tempVariable}=    Get Value    ${Id_to_check}

    Should Be Equal   ${expected_value}     ${tempVariable}

 

checkValuesDisabledField3

    [Arguments]    ${Id_to_check}    ${expected_value}

    Textfield Value Should Be   ${Id_to_check}    ${expected_value}


Hope it helps someone in the future

Thanks for your answers and advices


Le mercredi 4 avril 2018 15:59:29 UTC+2, Ludovic a écrit :
Reply all
Reply to author
Forward
0 new messages