0
votes

I'm currently working on automating a UAT for a program my company's working on. I did all the usual stuff like recording, clicking on relevant buttons and all, until I encounter a drop down menu.

The problem is that when selecting an item from the drop down, the action couldn't be recorded. After a while, I came to the solution of manually inserting the commands to choose the selected item from the drop down.

There is a small problem. While browsing the HTML code using the Chrome's own Developer tool, the class related to the drop down shows this:

[class="select2-offscreen" name="reference_type"]

But when I directly check the page source code, it shows this:

[select class="form-control" required="" id="reference_type" name="reference_type"]

The error shown in the log when I was testing the script wrote:

[[error] Specified element is not a Select (has no options)]

I would like to know your take on this and help me find solutions to overcome this problem. If you have anymore questions or want more info, do ask.

Thanks.

1
Can you provide the html of the intended element? Looking at the error it tells you the element is not a select in type. That might be the issue - Saifur
@saifur <div class="individu form-group col-md-12 col-sm-12 col-xs-12"> <label class="col-md-2 col-sm-3 col-xs-12 control-label">Jenis Rujukan</label> <div class="col-md-6 col-sm-5 col-xs-12"> <select class="form-control" required="" id="reference_type" name="reference_type"></div> <div class="col-md-4 col-sm-4 col-xs-12"> <span class="help-block"> </span> </div> </div> - MiracleOracle
The error is correct. I do not see any options. So select will not work - Saifur
@saifur so it means that i need to choose a different command? - MiracleOracle
Put the code in the original question so we can more easily read it. - DMart

1 Answers

0
votes

I'd guess it's one of 2 things

  1. As DMart said in the comments it's trying to select before the drop down has loaded, maybe put a 'waitforelement' in before the select command

  2. Something about the differing code (between chrome developer tools and the page source) is causing problems, I'm not sure what locator you're using for the drop down but maybe try using

    <tr>
        <td>select</td>
        <td>css=[name=reference_type]</td>
        <td>label=NRIC</td>
    </tr>
    

as the name is the only consistent attribute in the 2 variations you posted, so this way you're covered which ever one it's reading the page as.