Невозможно нажать кнопку в Lua Script с помощью Splash

Эта проблема по своей природе аналогична этому вопросу, но моя проблема все еще сохраняется после попробовав предложенное решение.

Я хочу, чтобы мой сценарий Lua реагировал на модальное всплывающее окно в случае его появления, закрывая его. Однако на последнем снимке экрана продолжает отображаться модальное всплывающее окно, что указывает на то, что оно не было закрыто.

Это начальная ссылка, из которой я хочу получить данные: «https://www.goodreads.com/search?utf8=%E2%9C%93&query=»

А вот мой Lua-скрипт:

function main(splash, args)
  splash.private_mode_enabled = false
  splash:set_user_agent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0")
  assert(splash:go(args.url))
  assert(splash:wait(0.5))

  input_box = assert(splash:select('#search_query_main'))
  input_box:focus()
  input_box:send_text("dostoevsky")
  input_box:send_keys("<Enter>")
  assert(splash:wait(1)) 

  if not splash:select('div.modal--centered div.modal__close') == nil then
    close_button = splash:select('div.modal--centered div.modal__close > button')
    close_button.style.border = "5px solid black"
    close_button:mouse_click()
  end
  splash:wait(1)

  return {
    num_modal = #splash:select_all('div.modal--centered div.modal__close'),
    num_close_btns = #splash:select_all('div.modal--centered div.modal__close > button'),
    html = splash:html(),
    png = splash:png(),
  }
end

Функция возвращает num_close_btns: 1 и num_modal: 1, что говорит о том, что мои css-селекторы в порядке, поэтому я могу только предположим, что событие mouse_click не делает того, что я ожидаю.

Скриншот модального всплывающего окна


person Luca Guarro    schedule 18.05.2021    source источник