Studiosity / grover

A Ruby gem to transform HTML into PDFs, PNGs or JPEGs using Google Puppeteer/Chromium
MIT License
945 stars 109 forks source link

Multiple classes to wait for with wait_for_selector option. #242

Closed Mohamed-Zkaria closed 4 months ago

Mohamed-Zkaria commented 5 months ago

Hi, How can I make grover to wait on multiple classes? I tried to pass the option like this: Grover.new(html, format: 'A4', wait_for_selector: [".map", ".pie"]) but it didn't work. Is there a different option for it?

abrom commented 5 months ago

see waitForSelector documentation; it does not support the form you're using, just a single selector. If you're wanting something more complicated then you'd likely use the wait_for_function method and pass in a function that queries both selectors are on the page. ie

wait_for_function: "!!document.querySelector('.map') && !!document.querySelector('.pie')"
Mohamed-Zkaria commented 4 months ago

Thank you appreciate your response.