开发者

Selenium Test (junit ) get stuck once the test spawns new window

开发者 https://www.devze.com 2023-03-23 17:57 出处:网络
Issue is once the new window is spawn test hangs after the line waitForPageToLoad(3000) and finally times out. Once the test hangs if i manually fire some event in parent window test starts executing

Issue is once the new window is spawn test hangs after the line waitForPageToLoad(3000) and finally times out. Once the test hangs if i manually fire some event in parent window test starts executing normally. So as a solution I tried adding code that selects parent window and fire some event. But this code doesn't work at all. If any one could point out where am I missing something or point out my wrong approach.

Steps I followed :

  1. Click the link that opens new window.(here link=3018)

  2. Once the new window2 opens no further action is automated and test just hangs until timeout interval after which it just throws timeout exception.

  3. Manually fire event(click link=outbox) on parent window1 before timeout interval.

  4. Test start executing normaly and finish successfully.

Code snippet (that works fine once manually firing evnt in parent window) :

            selenium.click("link=Last");
            selenium.waitForPageToLoad("30000");
            selenium.click("link=3018");
            selenium.waitForPageToLoad("30000");              
            selenium.selectWindow("window2");
            selenium.selectFrame("relative=up");
            selenium.click("687c55");
            selenium.waitForPageToLoad("30000");
            assertEquals("window2", selenium.getTitle());
            selenium.close();

Code snippet (that fails evn after adding code to select window and firing evnt in parent window) :

            selenium.click("link=Last");
            selenium.waitForPageToLoad("30000");
            selenium.click("link=3018");
            selenium.waitForPageToLoad("30000");
            selenium.selectWindow("window1");              
            selenium.click("link=Outbox");
            selenium.waitForPageToLoad("30000");
            selenium.selectWindow("window2");
            selenium.selectFrame("relative=up");
            selenium.click("687c55");
            selenium.waitForPageToLoad("30000");
            assertEquals("window2", selenium.getTitle());
            selenium.close();

I cannot find any reason why my code still fails after adding code to select parent window and to fire click event. It still just hangs and throws exception after time 开发者_开发技巧out. :(

Is there any bug with selenium handling popup windows ? Would like to have any suggestion regarding modification in my approach for handling pop up windows in selenium


Selenium RC handles pop-up windows just fine. Lots of our tests use them. You don't make it clear what command is timing out, but I'll guess it's either the selectWindow("window2") or the selectFrame("relative=up").

If the former, you've probably got the wrong window name - you should be using the same value as used in window.open(url, name, ...).

If the latter, well, does the pop-up window have multiple frames in it? In fact, now that I think about it, this is probably the failing command, as even in a multi-frame window, Selenium starts out focused on the topmost frame, so "relative=up" wouldn't work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号