点击链接后硒不会检测到新窗口 [英] Selenium won't detect new window after clicking link

查看:192
本文介绍了点击链接后硒不会检测到新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的硒脚本,我点击一个链接(也就是一帧或东西产生这样通过源搜索不会返回它里面),送我去重定向或者是快捷方式下载网站的PDF文件。点击该链接时,会出现PDF在新窗口中。不幸的是,SeleniumRC无法检测到新的窗口,即使我用wait_for_pop_up(我使用python顺便说一句,如果它事项)。

In my selenium script, I click a link (that is inside a frame or something generated so that a search through the source doesn't return it), which sends me to a site that redirects or is a shortcut to a download of a pdf. The pdf appears in a new window when this link is clicked. Unfortunately, SeleniumRC can't detect the new window, even if I use "wait_for_pop_up" (I'm using python btw, if it matters).

的webdriver可以检测到新的窗口,所以要解决这个让我一直在使用SeleniumRC和webdriver的组合,但它是如此越野车(如的webdriver我使用它,而不是组合),它是不能容忍的。我宁愿使用SeleniumRC的一切。

WebDriver can detect the new window, so to get around this I've been using a combination of SeleniumRC and WebDriver, but it's so buggy (WebDriver as I'm using it, not the combination) that it's intolerable. I'd rather use SeleniumRC for everything.

我怎样才能得到SeleniumRC检测到这个窗口?

How can I get SeleniumRC to detect this window?

编辑:让我澄清这个问题:当我告诉它去拿窗口的ID(在python window_handles),我希望窗口甚至没有出现,仿佛SeleniumRC不知道它的存在。的webdriver可以找到它虽然给它一个ID,所以我不知道这个是的。

let me clarify the issue: when I tell it go get window ids (window_handles in python), the window I want doesn't even appear, as if SeleniumRC doesn't know it exists. WebDriver can find it and give it an ID though, so I don't know what's up with this.

一个细节:与PDF的新窗口中有不同的(镜像)的域名,这可能是一个问题。

One more detail: the new window with the pdf has a different (mirror) domain name, could that be an issue?

推荐答案

有一个的有关如何在硒使用多个窗口的http://saucelabs.com/blog/index.php/2010/05/selenium - 提示,工作与 - 多窗口/相对=nofollow>此处。也许不是waitForPopup可以介绍一组时间手动等待(比如2秒),然后用selectWindow选择新窗口。

there is a good tutorial on how to use multiple windows in selenium here. Maybe instead of waitForPopup you can introduce a manual wait for a set time (say 2 seconds) and then use selectWindow to select the new window.

这篇关于点击链接后硒不会检测到新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆