"Click" doesn't seem to work with non-button URL

I successfuly used “click” on button with Puppetter, but when it comes to text URL, it seems it doesn’t work.

I want to click on the link " Gestion des cookies" at the very bottom of the page.

=====>

The thing, it’s a iframe, which appears on the page itself, with <a href = #, I can’t get the full URL. It’s supposed to look like this :

If I try to click on the link, and get the source code, there is no such this iframe.

Here the code (I got the selector from Google Chrome’s inspect element, so I don’t think it comes from here because I used “copy selector” for other tasks with Pupeeter and it worked)

BLOCK:PuppeteerOpenBrowser

ENDBLOCK

BLOCK:PuppeteerNewTab

ENDBLOCK

BLOCK:PuppeteerNavigateTo

  url = "https://www.lemonde.fr/"

  loadedEvent = DOMContentLoaded

ENDBLOCK

BLOCK:PuppeteerClick

  findBy = Selector

  identifier = "#js-body > footer > section > section.footer__main > section.footer__middle > section:nth-child(3) > ul > li:nth-child(4) > a"

ENDBLOCK

BLOCK:PuppeteerGetDOM

  => VAR @puppeteerGetDOMOutput

ENDBLOCK

Did you switch to the iframe first? You have to use a SwitchToFrame block first

I did not at the time of my posting, but I tried and it did not change anything, because “wait for element” for the button “tout accepter” of the iframe doesn’t show up …

BLOCK:PuppeteerOpenBrowser

ENDBLOCK

BLOCK:PuppeteerNewTab

ENDBLOCK

BLOCK:PuppeteerNavigateTo

  url = "https://www.lemonde.fr/"

  loadedEvent = DOMContentLoaded

  timeout = 50000

  SAFE

ENDBLOCK

BLOCK:PuppeteerSwitchToFrame

  findBy = Selector

  identifier = "#js-body > footer > section > section.footer__main > section.footer__middle > section:nth-child(3) > ul > li:nth-child(4) > a"

ENDBLOCK

BLOCK:PuppeteerClick

  findBy = Selector

  identifier = "#js-body > footer > section > section.footer__main > section.footer__middle > section:nth-child(3) > ul > li:nth-child(4) > a"

ENDBLOCK

BLOCK:PuppeteerWaitForElement

  findBy = Selector

  identifier = "#js-body > div.gdpr-lmd-params > div > div.gdpr-lmd-params__top-actions > button.gdpr-lmd-button.gdpr-lmd-button--main"

  timeout = 50000

ENDBLOCK

BLOCK:PuppeteerGetDOM

  => VAR @puppeteerGetDOMOutput

ENDBLOCK

Here the log :

>> Open Browser (PuppeteerOpenBrowser) <<

Headless Browser opened successfully!

 

>> New Tab (PuppeteerNewTab) <<

Opened a new page

 

>> Navigate To (PuppeteerNavigateTo) <<

Navigated to https://www.lemonde.fr/

 

>> Switch to Frame (PuppeteerSwitchToFrame) <<

Switched to iframe

 

>> Click (PuppeteerClick) <<

Clicked 1 time(s) with Left button

 

>> Wait for Element (PuppeteerWaitForElement) <<

[Executing block Wait for Element] WaitTaskTimeoutException: waiting for selector '#js-body > div.gdpr-lmd-params > div > div.gdpr-lmd-params__top-actions > button.gdpr-lmd-button.gdpr-lmd-button--main' failed: timeout 50000 ms exceeded

BOT ENDED AFTER 158817 ms WITH STATUS: ERROR

What do you have to set in “iframe” btw ? I chose “selector” for the url

Forget about it, I found another button directly on the homepage to click on to accept cookies

You have to target the <iframe> element

Yeah, I understood after.

One more thing : is “safe mode” only for debugger ? I need to use “wait for naviguation” but without page reloading, just like an “await”, but if nothing is really reloaded, I get an error : in the debugger with safe mode activated, I can jump the error and continue to execute block, I would like to do the same when i’ll use wordlist

No, safe mode is actually written to the final code as a try/catch block so it will also work in the job.

1 Like