Window.close and self.close dont work when Played, works when double clicked


#1

Hi, this test:

open | www.google.com
runScript | window.open("http://www.google.com")
pause | 2000 
runScript | window.close("http://www.google.com")
runScript | window.close("")
runScript | self.close("")

doesnt work on firefox when using “Play” option
If i double click on any of the last 3 commands they will successfully close the current tab (window)
But the “Play” will just mark them green and move on, without actually closing the window.

Test done in Firefox

Any idea why is this happening, and how can i make it work ?


#2

anyone ? i coudl really use some help here


#3

I can open and close a window like this

open | https://www.google.com| |
openWindow | https://www.google.com | winID |
selectWindow | winID | |
pause | 2000 | |
close | | |

or like this

open | https://www.google.com | |
runScript | document.myWindow = window.open("https://www.google.com") | |
pause | 2000 | |
runScript | document.myWindow.close() | |

Note that there is a security feature of JavaScript that means only windows that have been opened with JavaScript can be closed by JavaScript.

Also note the first method only seems to work with new tabs. If it is run again on the same tab an error occurs

[error] TypeError: Cannot read property 'root' of undefined

#4

Thanks, somewhat this works but not really…

First solution doesnt work at all,

 [info] Executing: | openWindow | https://www.google.com | winID |

 [error] 'open' called on an object that does not implement interface Window.

The second solution works, but im unable to read the content of the newly created window.
I try to do :

 storeText | //body |AllText_1

between lines 3&4 but what happens is the body of the page BEFORE is stored in the variable, not from the newly created window :frowning:

So the problem is :

open | https://www.google.com | |
runScript | document.myWindow = window.open("https://www.gmail.com") | |
pause | 2000 | |
storeText | //body |AllText_1
runScript | document.myWindow.close() | |

And the Variable AllText_1 contains the text from google.com, while it should’ve grabbed it from gmail.com

Anything we can do about that ?
thx !


#5

There does seem to be a problem. I thought my examples were working but it was only because I was using the same URL for open and openWindow, but if I use different URLs then only the text from the first window is stored.
I tried using document.myWindow.focus() and openWindowAndWait and all sorts of combinations, but nothing worked.
I’m probably missing something here so I’ll have to go back to the drawing board :confused: