无法处理硒中的弹出窗口+ IE9

发布于 2025-01-07 06:45:18 字数 554 浏览 5 评论 0原文

我试图找到当我使用 Selenium 单击链接时打开的弹出窗口的 ID。

代码是

public String getWindowId() {
        String feedWinId = test.getEval("{var windowId; for(var x in                    selenium.browserbot.openedWindows ) {windowId=x;} }");
        return feedWinId;
        //return feedWinId.contains("chat");
    }

现在这适用于 Firefox,但在 IE 9 上返回 null。知道为什么吗? IE 也有解决

方法我的要求只是检查单击链接时是否打开了弹出窗口。一旦获得 WindowId,我就会使用类似的方法

test.waitForPopUp(getWindowId(), ResourceConstants.POPUP_TIMEOUT);

来检查弹出窗口

I am trying to find the id of a popup window which opens when I click on a link using Selenium.

The code is

public String getWindowId() {
        String feedWinId = test.getEval("{var windowId; for(var x in                    selenium.browserbot.openedWindows ) {windowId=x;} }");
        return feedWinId;
        //return feedWinId.contains("chat");
    }

Now this is working for Firefox but it returns null on IE 9.Any idea why ? also is there a workaround for IE

P.S. My requirement is simply to check if a popup opened when the link was clicked.Once I get the WindowId, i use something like

test.waitForPopUp(getWindowId(), ResourceConstants.POPUP_TIMEOUT);

to check fo the popup

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

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

发布评论

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

评论(1

盛夏已如深秋| 2025-01-14 06:45:18

您是否尝试过selenium.GetAllWindowIds();
然后使用 selenium.selectwindows(windowId); 切换到一个窗口,并检查它是否是您想要的弹出窗口。

String[] ids = selenium.GetAllWindowIds();
for (int i = 0; i < ids.length; i++)
{
    selenium.WaitForPopUp(ids[i], "30000");
    selenium.selectwindow(pids[i]);
    //check if it is your popup
    //if yes then break;
}

Have you tried selenium.GetAllWindowIds();?
Then switch to a window with selenium.selectwindows(windowId);and check if it is the popup you wish.

String[] ids = selenium.GetAllWindowIds();
for (int i = 0; i < ids.length; i++)
{
    selenium.WaitForPopUp(ids[i], "30000");
    selenium.selectwindow(pids[i]);
    //check if it is your popup
    //if yes then break;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文