“result is null” error when working around _blank

2019-09-07 05:01发布

问题:

Using a workaround to be able to check the contents of a new tab, I get unexpected results. If I play the test case, the following line fails:

storeEval | javascript{"selenium.browserbot.getCurrentWindow().open('', 'my_window')"} | my_window

with the following error message:

[error] Threw an exception: result is null

The following alternative statements show the exact same symptoms:

getEval | window.open("", "my_window")
getEval | selenium.browserbot.openWindow("", "my_window")

Now, if I double-click it, it doesn't fail, but it opens up a new window, which I think the original solution didn't intend (the next step is to click on a link in the parent window, after all). At this point I can click on the parent window, manually run the next step to launch the link, manually change back to the child window (selectWindow | my_window says it can't find that window), and manually run each of the following steps to check the contents of the new window.

How do I proceed from here to make the test properly automatic?

Update: There is a built-in action for opening windows, but it also fails. Maybe this verbatim log output can shed some light on what's going on:

[info] Executing: |store | license_window | windowName |
...
[info] Executing: |openWindow | | ${windowName} |
[error] Unexpected Exception: fileName -> chrome://selenium-ide/content/recorder.js, lineNumber -> 74

The relevant lines from recorder.js:

66: window.open = function(url, windowName, windowFeatures, replaceFlag) {
...
74:            if (result.wrappedJSObject) {
75:                result = result.wrappedJSObject;
76:            }

回答1:

It seems that your browser doesn't allow pop-up for your web site. Go to options > Content > Exceptions for block pop-up windows and add your web site address.