简体   繁体   English

如何使用watir从弹出页面访问数据?

[英]How I can access the data from a popup page with watir?

I want to access the data in a popup window containing a login form, this window opens when you click on a logo, this line contains the code to execute the javascript: <div id="loadDIV" class="containerLogo" onclick="ventanaSecundaria('/Security-war/autentia/Login.jsp?sion=c5ac379249711c18cf6e030c8400',800,600); "></div> 我想访问包含登录表单的弹出窗口中的数据,单击徽标时此窗口打开,此行包含执行javascript的代码: <div id="loadDIV" class="containerLogo" onclick="ventanaSecundaria('/Security-war/autentia/Login.jsp?sion=c5ac379249711c18cf6e030c8400',800,600); "></div>

with this line run the script: browser = browser.div(:class => "containerLogo").fire_event :click watir open in a new popup form. 在此行中运行脚本: browser = browser.div(:class => "containerLogo").fire_event :click以新的弹出窗口打开的watir。 The problem is that I can not access the data from the popup window and need to fill the form containing, try the following: puts browser.text.include? 'Login' 问题是我无法从弹出窗口访问数据,需要填写包含的表单,请尝试以下操作: puts browser.text.include? 'Login' puts browser.text.include? 'Login' and get false, then I thought that maybe I could not access the other popup and look for something to not open another window but only refresh the I'm using and so we can access its contents, looking I found that I can do this: browser.goto("javascript:document.getElementByClass()'containerLogo').click()") but I try to console returns 'true' and the browser does not update. puts browser.text.include? 'Login'并得到错误,然后我想也许我无法访问另一个弹出窗口并寻找无法打开另一个窗口的东西,而只能刷新我正在使用的窗口,因此我们可以访问其内容,看上去我发现我可以这样做: browser.goto("javascript:document.getElementByClass()'containerLogo').click()")但我尝试通过控制台返回“ true”,并且浏览器不会更新。

Update You can switch windows simply with this: browser.window(:index => 1).use 更新您可以使用以下命令简单地切换窗口: browser.window(:index => 1).use

and to be sure we change verify the url window with this: 并确保我们更改以下内容来验证网址窗口:

browser.window.url

When a new browser window is opened, you can then 'use' the new window. 打开新的浏览器窗口后,您可以“使用”新窗口。 [Browser Popups | [浏览器弹出窗口| Watir Webdriver] Watir Webdriver]

browser.window(:title => "annoying popup").use do
  browser.button(:id => "close").click
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM