Celerity - 帮助 popup_browser 选择列表更新主浏览器上的 div 文本

发布于 2024-10-09 17:40:38 字数 777 浏览 3 评论 0原文

我正在屏幕抓取一个页面,其中包含一个链接,该链接会生成一个弹出窗口,该窗口由一个选择列表和一个用于执行选择的按钮组成。目的是单击主页上的链接,在弹出窗口中进行选择,单击链接确认选择,然后在主页上查看新的选择。

以下是我在 Celerity 中采取的步骤和结果:

popup_browser = browser.image(:alt, 'Holidays').click_and_attach
#this creates a new browser to deal with the popup window
popup_browser.select_list(:id, 'ddlSlot1').select_value('Christmas')
#Selecting Christmas from the select list
popup_browser.link(:id, 'btnChangeHoliday').click
#Confirms/Implements selection
popup_browser.close
#Closes popup browser
puts browser.div(:id, 'HolidayName').text
#Here I try to print the updated holiday but nothing is printed (no text value)

除了最后一行之外,一切似乎都工作正常。我已经做了一些调试并确认我的选择已做出。当我点击弹出页面上的 ChangeHoliday 按钮后,主网页似乎没有更新。

任何想法或建议将不胜感激。

预先感谢您的帮助。

I'm screen scraping a page that includes a link that spawns a popup window that is comprised of a select list and a button to execute your selection. The objective is to click the link on the main page, make a selection on the pop-up window, click the link to confirm the selection and then view the new selection on the main webpage.

Here are the steps that I'm taking in Celerity and the results:

popup_browser = browser.image(:alt, 'Holidays').click_and_attach
#this creates a new browser to deal with the popup window
popup_browser.select_list(:id, 'ddlSlot1').select_value('Christmas')
#Selecting Christmas from the select list
popup_browser.link(:id, 'btnChangeHoliday').click
#Confirms/Implements selection
popup_browser.close
#Closes popup browser
puts browser.div(:id, 'HolidayName').text
#Here I try to print the updated holiday but nothing is printed (no text value)

Everything seems to work fine except for the last line. I've done some debugging and have confirmed that my selection has been made. It seems that the main webpage is not being updated after I click the ChangeHoliday button on the popup page.

Any thoughts or suggestions would be appreciated.

Thanks in advance for you help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

私藏温柔 2024-10-16 17:40:38

事实证明这是一个简单的解决方法。脚本工作所需的唯一更改是将重新同步选项添加到浏览器初始化中。执行此操作后,脚本将按预期工作。

browser = Celerity::IE.new(:resynchronize => true)

This turned out to be an easy fix. The only change required for the script to work is to add the resynchronize option to the browser initialization. After doing so the script works as expected.

browser = Celerity::IE.new(:resynchronize => true)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文