0

I'm trying to click on time interval select option on the website Costco, since I am building automation, I am selecting each time interval one by one using JS. But I've tried multiple solutions but nothing appears when I click on "Select" element using JS, Iw ould like to know any possible solution that may help me, as Iterating over each time interval and selecting each of the receipt is must requirement for this project. Thank you in advance

bold What I have tried

// Dispatch change event

  var simulateMouseEvent = function (
            element,
            eventName,
            coordX,
            coordY
          ) {
            element.dispatchEvent(
              new MouseEvent(eventName, {
                view: window,
                bubbles: true,
                cancelable: true,
                clientX: coordX,
                clientY: coordY,
              })
            );
          };

          var elementToClick = document.getElementById("Showing");

          var box = elementToClick.getBoundingClientRect(),
            coordX = box.left + (box.right - box.left) / 2,
            coordY = box.top + (box.bottom - box.top) / 2;
          simulateMouseEvent(elementToClick, "click", coordX, coordY);
    ```

Frosty
  • 48
  • 5
  • https://www.costco.com/myaccount/#/app/[GENERATEDI]/ordersandpurchases --> In-warehouse purchases – Frosty May 22 '23 at 16:35
  • Sorry, I couldn't understand what you are trying to do. By chance, what you're wanting to do is just perform a CLICK on the SELECT component? only that? – Tales Born May 22 '23 at 16:37
  • @TalesBorn yeah but im clicking on that select component so the dropdown appears and I select any particular timeinterval or option, but the dropdown is not being appeared when I click on the select element. – Frosty May 22 '23 at 16:38
  • @Frosty why do you want to do this? wouldn't it be easier just to set the value in the select? – Tales Born May 22 '23 at 16:43
  • @TalesBorn Setting the value doesn't updates the tab below, every option is associated with list of receipts, if I manually select particular option from .value , it doesn't refreshes the receipts due to which I want the dropdown to open and then somehow click on option from there so the receipts refreshes. – Frosty May 22 '23 at 16:44
  • Is it an actual "select" element or is is something else? – epascarello May 22 '23 at 16:44
  • @epascarello yeah actual JS select element but nothing happens when you click on it through JS, which is very strange from JS perspective – Frosty May 22 '23 at 16:45
  • 1
    so select the value and fire the change event. https://stackoverflow.com/questions/19329978/change-selects-option-and-trigger-events-with-javascript – epascarello May 22 '23 at 16:45
  • exactly, as @epascarello commented – Tales Born May 22 '23 at 16:47
  • @epascarello Life savior, thank you so much! – Frosty May 22 '23 at 16:51

0 Answers0