0

I have this dropdown menu and I am trying to find the destination url for the "Edit" dropdown item. Is there any way to get this url with puppeteer?

<div _ngcontent-c34="" class="dropdown-menu" ngbdropdownmenu="" x-placement="bottom-right" style="top: 19px; left: -41px;">
<!---->
<i _ngcontent-c34="" class="dropdown-item ng-star-inserted" ngatranslatedtext="" tabindex="0">Edit</i>
<!---->
<i _ngcontent-c34="" class="dropdown-item ng-star-inserted" ngatranslatedtext="" tabindex="0">Delete</i>
</div>
Christian
  • 834
  • 7
  • 18
  • 1
    Please provide more information. What exactly do you mean with destination link? – Raukaute Feb 05 '23 at 13:32
  • A click on the "Edit" menu-item opens a new tab with a specific url. I want to find out what this url is. – Christian Feb 05 '23 at 13:35
  • What site is this and have you tried writing code so far? – ggorlen Feb 05 '23 at 16:22
  • What I don't see is, where this URL is supposed to be coming from - I can't see that in the markup you provided. Is it stored as an attribute on the tag? – Raukaute Feb 06 '23 at 07:10
  • @Raukaute yes, that is exactly my problem. I have no idea if the destination url is supposed to be stored somewhere on that page or if it could be hidden. I have no idea where or what to look for. – Christian Feb 06 '23 at 10:20
  • @Christian It still does not make sense to me. Where does the code in your example come from? Did you write it? – Raukaute Feb 10 '23 at 10:57
  • @Raukaute no I didn't write it. It is from a password-protected website that I would like to scrape. – Christian Feb 10 '23 at 15:19
  • 1
    You will probably have to make use of the waitForNavigation api. Something like described in this post:(https://stackoverflow.com/questions/52900248/how-to-listen-to-history-pushstate-with-puppeteer). To go another way, you’d have to find out how the event is handled on the page site. DevTools might help revealing it. – Raukaute Feb 11 '23 at 13:05

1 Answers1

1

Please bind & get the new page url.

  page.on('newpage', async (new_page) => {
        const url = new_page.url;
});
Naeem Ahmed
  • 216
  • 1
  • 6
  • So it is only possible by visiting the new page? – Christian Feb 05 '23 at 19:53
  • Yes, you need to bind that event on the existing page where that dropdown will be displayed & once click on 'dropdown-item' then you have url inside the newPage page event of that new page. – Naeem Ahmed Feb 06 '23 at 06:30