在文本字段中输入在网页中不起作用

问题描述 投票:0回答:1
javascript html web
1个回答
0
投票

我认为你完全搞乱了代码。这是JS版本。

尝试让我知道它是否有效。

var inputElement = document.getElementById('FieldWrapper-0'); 
inputElement.value = "TEXT"; 
var event = new KeyboardEvent('keydown', { 'key': 'Enter' })
inputElement.dispatchEvent(event, { bubbles: true }); 



inputElement.addEventListener('keydown', function () {
        alert('Keyboard Clicked');
 });
I am trying to automate a process on webpages. The element is

<input aria-expanded="false" 
       aria-owns="search-dropdown-results" 
       data-accessibility-id="header-search-input-field" 
       data-anchor-id="HeaderSearchInputField" 
       data-lpignore="true" type="text" 
       autocomplete="off" 
       placeholder="Search stores, dishes, products" 
       inputmode="search" id="FieldWrapper-0" 
       aria-describedby="search-dropdown-results" 
       class="Input__InputContent-sc-1o75rg4-3 idveBz" 
       value="">

© www.soinside.com 2019 - 2024. All rights reserved.