Selenium won't detect new window after clicking link

旧时模样 提交于 2019-12-12 02:39:34

问题


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 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.

How can I get SeleniumRC to detect this window?

Edit: 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.

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


回答1:


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.




回答2:


You can get control on the new window, by just opening that window using selenium again . Ie get the url of the new window manually after clicking on the lick which opens it, then use selenium.open("your new window url"); and go ahead with the rest of operations in that page.



来源:https://stackoverflow.com/questions/7465638/selenium-wont-detect-new-window-after-clicking-link

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!