问题描述
这个问题本质上类似 to this question,但在尝试提供的解决方案后,我的问题仍然存在。
我希望我的 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 事件没有做我期望它做的事情。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)