18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Select empty option from a drop down

SudhakarSudhakar Members
edited November -1 in Sahi - Open Source
Hi all,

I came across a problem where in there is a need to select an empty option in a dropdown and continue to check if page validates the field or not.
my screen has a dropdown and by default it contains a value when page loads.
but i need to set it as empty and check for the validation error.


i am passing the value from a CSV format, below is the example.

_setSelected(_select(/Status/), $mainrs[$i]["status"]);

In the above example i tried passing space from CSV file, but it does'nt act on that.

If anyone came across this type of issue , please let me know.

Comments

  • narayannarayan Administrators
    Is there a blank opiton in that dropdown?
    Could you paste the HTML code of the dropdown here? (Paste it within [ code ] [ /code ] tags so that it is correctly escaped.)
  • Yes, there is a blank option in that dropdown.
    <span class="">Status:</span></td><td style="padding:3" colspan="16" rowspan="1" class="">
    <select name="4c1c4d12-3875-46b4-a6e3-8a0ee0742db5.authStatusEnum" 
                                                                       value="ARCPrStActv" tabindex="" elementstyle="">
    <option value=""></option>
    <option value="ARCPrStActv" SELECTED="1">Active</option>
    <option value="ARCPrStInactv">Inactive</option>
    </select>
    

    You can view above tags that specify space.
    As i understand i have to paste the above code between tags.

    if that is the case, then i can't make a change at code end.
    i have to manipulate everthing through SAHI with out changing the app code.

    could you please specify any alternative.
  • narayannarayan Administrators
    Hi Sudhakar,

    With [ code ] [ /code ], I mean use it when you reply on the forum, so that html is properly escaped and the code appears in a box :)

    Anyway, I will need to check why "" did not work. Meanwhile you can use:
    var $status = $mainrs[$i]["status"];
    if ($status == "") $status = 0;
    _setSelected(_select(/Status/), $status);
    

    This is hacky, ugly and works only in your case, but please bear with it till I fix the issue!

    Regards,
    Narayan
Sign In or Register to comment.