Results 1 to 2 of 2

Thread: Selection of a value in a list (webview2)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2022
    Posts
    27

    Selection of a value in a list (webview2)

    Hello,

    I am trying to select a value from a drop down list. Previously it worked very well but since the update of my CMS it no longer works.

    There is a difference between the source code of the page seen by the browser and the source code that I retrieve via webviewer.

    browser (edge)
    HTML Code:
    <select id="jform_catid" name="jform[catid]" required class="required">
    	<option value="2">XXXXXXXXX</option>
    	<option value="3">XXXXXXXXX</option>
    	<option value="9">XXXXXXXXX</option>
    </select>
    My old code that worked is:
    Code:
    WebView21.ExecuteScriptAsync("document.getElementById('jform_catid').value = '8';")

    webviewer2 see :
    HTML Code:
    <joomla-field-fancy-select placeholder="- Catégorie -"><div class="choices" data-type="select-multiple" role="combobox" aria-autocomplete="list" aria-haspopup="true" aria-expanded="false">
    <div class="choices__inner">
    <select id="filter_category_id" name="filter[category_id][]" multiple="" onchange="this.form.submit();" class="choices__input" hidden="" tabindex="-1" data-choice="active"></select>
    <div class="choices__list choices__list--multiple"></div>
    <input type="text" class="choices__input choices__input--cloned" autocomplete="off" autocapitalize="off" spellcheck="false" role="textbox" aria-autocomplete="list" aria-label="- Catégorie -" placeholder="- Catégorie -" style="min-width: 14ch; width: 1ch;">
    </div>
    <div class="choices__list choices__list--dropdown" aria-expanded="false">
    <div class="choices__list" aria-multiselectable="true" role="listbox"><div id="choices--filter_category_id-item-choice-1" class="choices__item choices__item--choice choices__item--selectable is-highlighted" role="option" data-choice="" data-id="1" data-value="2" data-select-text="Cliquer pour sélectionner" data-choice-selectable="" aria-selected="true">XXXXXXXXXXX</div>
    <div id="choices--filter_category_id-item-choice-2" class="choices__item choices__item--choice choices__item--selectable" role="option" data-choice="" data-id="2" data-value="3" data-select-text="Cliquer pour sélectionner" data-choice-selectable="">XXXXXXXXXXX</div>
    <div id="choices--filter_category_id-item-choice-3" class="choices__item choices__item--choice choices__item--selectable" role="option" data-choice="" data-id="3" data-value="9" data-select-text="Cliquer pour sélectionner" data-choice-selectable="">XXXXXXXXXXX</div></div></div></div>
    </joomla-field-fancy-select>
    I try this :
    Code:
    WebView21.ExecuteScriptAsync("document.getElementById('choices--filter_category_id-item-choice-3')[0].click();")

    It does not work. I tried many solutions but nothing works

    Thank you for your precious help

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: Selection of a value in a list (webview2)

    That is because technically speaking there aren't any options in the select.

    Does the website you're automating provide an API? If not, could you provide us with the corresponding JavaScript source code for the page so that we could see what happens when one of the ".choices__item" elements are clicked?
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width