skip to Main Content

Currently there is an input field that displays a search drop down as soon as I click on it , but If I store the field as a global variable and try temp1.select() in chrome console ( temp1 is the name of the global variable) it does not work
However this works when the tab is in the background(not the current tab I am viewing), when I go to the current tab the drop down is already open

after temp1.select() If I click somewhere else on the screen except on the input field it simultaneously opens and closes the search drop down
This could be due to the event stored in a stack but not flushed , But I am note sure how to force the flush of the events
Is there any function that could do this ?

this is the html code

<input aria-label="Search Test" autocomplete="off" 
placeholder="Search Test" id="ember1168" class="ember-text-field 
input--text composable-select__input ember-view" type="text">

2

Answers


  1. Chosen as BEST ANSWER

    After trying out multiple commands I think this works for me, I think we have to focus and then click

    $(element).focus().trigger('click');
    

    element could be selected using Xpath here.

    In my case it was

    $(document.querySelectorAll("*[placeholder="Search test"]")[0]).focus().trigger('click');
    

  2. this is going to be app-dependent, but you’d probably need to disable the click-outside behavior of the select to prevent it from closing.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search