Рельсы капибары заполняют угловую форму без идентификатора и имени на полях - PullRequest
0 голосов
/ 31 октября 2019

Для очень конкретного случая использования после транзакции мне нужно войти в другую систему (сборка с Angular), чтобы заполнить форму. Вход в систему работает нормально, перейдя к правильной ссылке, чтобы создать новую запись, показывающую модальную форму работы. Теперь мне нужно ввести поле, которое автоматически заполняет список в стиле

<ul>
  <li><a class="ng-scope ng-binding"><strong>AAA</strong></a></li> 
  <li><a class="ng-scope ng-binding"><strong>BBB</strong></a></li>
</ul>

Ни один из элементов UL, LI или A не имеет идентификатора или имени. Как выбрать первый вариант из LI?

рельсы 5.2
капибара
селен

HTML-фрагмент страницы

<form id="addedit-transfer_form" class="form-horizontal form-condensed ng-scope ng-invalid ng-invalid-required ng-dirty" ng-controller="RepeaterCtrl">

    <!-- ngRepeat: line in repeaterLines --><table class="table table-striped table-condensed ng-scope" ng-repeat="line in repeaterLines">

<tr class="offset1">
    <td>
        <input name="model[0][Destinations][0][ShipmentLicenseType]" type="hidden" value="Licensed">
        <div class="control-group">
            <label class="control-label"><strong class="ng-binding">Destination 1</strong></label>
            <div class="controls">
                <div class="input-append">
                    <input autocomplete="off" class="js-validated-element validate[required] ng-dirty ng-invalid ng-invalid-required" placeholder="Type part of the License Number..." required="" spellcheck="false" type="text" ng-model="destination.RecipientId" typeahead="facility.Id as facility.LicenseNumber + ' | ' + facility.FacilityName for facility in preload.repeaterData.DestinationFacilities | orderBy:'LicenseNumber' | filter:$viewValue | limitTo:10" typeahead-editable="true" ng-blur="globalMethods.typeaheadValidator(preload.repeaterData.DestinationFacilities, 'Id', destination, 'RecipientId');" typeahead-input-formatter="globalMethods.typeaheadFormatter(preload.repeaterData.DestinationFacilities, destination.RecipientId, 'Id', 'LicenseNumber');" typeahead-on-select="validateSelection(preload.repeaterData.DestinationFacilities, [[$parent.$index, 'Destinations', 'Transfer'], $index], ['Id', 'RecipientId'], 'LicenseNumber', false, false, preload.defaults.destinationLine);" id="form-validation-field-0">
<ul class="typeahead dropdown-menu ng-isolate-scope" ng-style="{display: isOpen()&amp;&amp;'block' || 'none', top: position.top+'px', left: position.left+'px'}" typeahead-popup="" matches="matches" active="activeIdx" select="select(activeIdx)" query="query" position="position" style="display: block; top: 57px; left: 182px;">

<!-- ngRepeat: match in matches --><li ng-repeat="match in matches" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index)" class="ng-scope active">
                    <a tabindex="-1" bind-html-unsafe="match.label | typeaheadHighlight:query" class="ng-scope ng-binding"><strong>020-100815612A0</strong> | 12/12 INDO</a>
                </li><!-- end ngRepeat: match in matches -->
                </ul>
                    <button class="js-destinationsearch-0-0 btn js-destinationsearch" data-id-field="Id,RecipientId" data-index="0" data-sublists="0,Destinations" data-sibling-validator="typeahead-on-select" data-popover-updater="" type="button" data-original-title="" title="">
                        <span class="icon-search"></span>
                    </button>
                    <input name="model[0][Destinations][0][RecipientId]" type="hidden" value="">
                </div>
                <button class="btn btn-info btn-mini" type="button" ng-click="removeLine($index, line.Destinations, true, preload.defaults.destinationLine); preload.methods.createNewControls();">
                    <span class="icon-minus-sign ng-hide" ng-hide="line.Destinations.length === 1"></span><span ng-show="line.Destinations.length === 1" class="">(clear)</span>
                </button>
            </div>
        </div>

введите правильную информациюв поле с заполнителем placeholder = "Введите часть номера лицензии ..." работает, затем показывает часть ul / li, которая требует выбора для установки скрытого поля

1 Ответ

0 голосов
/ 01 ноября 2019

Вы не упоминаете, как вам нужно выбрать из этого списка, но если вам просто нужно щелкнуть по нему, вы можете сделать

click_link('AAA')

Если вам нужно более конкретное, чем вы могли бы сделать

find('li > a', text: 'AAA').click

и т. Д.

Предполагается, что вы уже отправили соответствующие нажатия клавиш на вход, чтобы появился список.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...