25 Replies Last post: Nov 19, 2008 10:10 AM by Haw-Bin Chai   Go to original post 1 2 Previous Next
David Beginner 7 posts since
Sep 18, 2008
Currently Being Moderated
15. Sep 18, 2008 4:44 PM in response to: Haw-Bin Chai
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

It is saying that is is not a function.

 

 

====Stack Trace====

errorUnexpected Exception: message -> selenium.browserbot.getCurrentUnwrappedWindow is not a function, fileName -> chrome://selenium-ide/content/tools.js -> file:///C:/Documents%20and%20Settings/ddunham/My%20Documents/Projects/Omniture/testing/user-extensions.js, lineNumber -> 114, stack -> ()@chrome://selenium-ide/content/tools.js -> file:///C:/Documents%20and%20Settings/ddunham/My%20Documents/Projects/Omniture/testing/user-extensions.js:114 ()@chrome://selenium-ide/content/tools.js -> file:///C:/Documents%20and%20Settings/ddunham/My%20Documents/Projects/Omniture/testing/user-extensions.js:101 ("","")@chrome://selenium-ide/content/tools.js -> file:///C:/Documents%20and%20Settings/ddunham/My%20Documents/Projects/Omniture/testing/user-extensions.js:64 apply(object Object,[object Array])@:0 ("","")@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 (object Object,[object Object])@chrome://selenium-ide/content/selenium/scripts/selenium-commandhandlers.js:307 ()@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:112 (5)@chrome://selenium-ide/content/selenium/scripts/selenium-executionloop.js:78 apply(object Object,[object Array])@:0 (5)@chrome://selenium-ide/content/selenium/scripts/htmlutils.js:60 @:0 , name -> TypeError

==================================================

 

 

======Snippet from user-extensions.js======

 

Selenium.prototype.doAesDumpOmniture = function(params) {

AES.dumpOmnitureVars();

};

BrowserBot.prototype.getCurrentUnwrappedWindow = function() {

var currentWindow = this.currentWindow;

return (currentWindow.wrappedJSObject

? currentWindow.wrappedJSObject

: currentWindow);

};

var AES = {

dumpOmnitureVars:function() {

var s = this.getWindow().s;

if (typeof s === 'undefined' || s === null) {

alert("No Omniture vars");

return;

}

for (var i in s) {

if (/\beVar\d+|\bprop\d+/.test(i)) {

str += '\ns.' + i + "=" + s+;

}

}

alert( str );

},

getWindow:function() {

return selenium.browserbot.getCurrentUnwrappedWindow();

},

};

 

Message was edited by: David (fixed, the formatting killed the embedded script)

Beginner 9 posts since
Feb 7, 2008
Currently Being Moderated
16. Sep 29, 2008 11:31 AM in response to: David Burns
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

Hi Guys,

Any solution to this yet?

I am using Selenium IDE 1b2

and I have the following javascript: snippet as part of my page source;

 

     <script language="javascript" type="text/javascript">
           var box_name = "Wide Centre";

I am trying to verify the value of box_name using;

<td>verifyEval</td>
    <td>this.browserbot.getCurrentWindow().box_name</td>
    <td>Wide Centre</td>

and it fails. This used to work in 0.87

Anything that works or alternative way to assert the variable will be great.

byno

Haw-Bin Chai Master 515 posts since
May 19, 2006
Currently Being Moderated
17. Sep 30, 2008 12:21 PM in response to: byno
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

Yeah, this is really annoying. Adding the new method to the BrowserBot prototype doesn't seem to work for me either, and I'm not sure why.

 

Another possibility is to use the runScript command. This actually inserts script tags into the page. It wouldn't make sense to me that these scripts would suffer from the same limitations as the wrapped windows, but there's only one way to find out for sure.

 

runScript | alert('foo')

 

 

 

Haw-Bin

David Beginner 7 posts since
Sep 18, 2008
Currently Being Moderated
18. Oct 1, 2008 2:16 PM in response to: Haw-Bin Chai
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

I'm testing that certain javascript variables are populated on various pages of my applications, I've had to go back and install .87 and have been able to run my tests with it, I miss being able to use the suite but I am able to test everything I need (for now).

This bug is blocking me from using 1b2.

Beginner 9 posts since
Feb 7, 2008
Currently Being Moderated
19. Oct 1, 2008 6:24 PM in response to: David
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

I have had to do the same thing - revert to version 0.87, to run one of the tests in my test suite. The problem though is that i have other tests within that suite that are using commands that exist only in 1.b2. So it is now impossible to click a button and have the tests run.

Is there any way forward? Do we expect a 1.b3 soon? A patch? User Extension? Anything that can bring back the browserbot functionality to 1.b2?

Cheers

byno

Beginner 9 posts since
Feb 7, 2008
Currently Being Moderated
20. Oct 3, 2008 10:41 AM in response to: byno
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

Hi Guys,

I tried the  workaround offered by Haw-Bin (thread 4) which is to replace

BrowserBot.prototype.getCurrentWindow = function(doNotModify) {
    ...
    var testWindow = this.currentWindow;
    ...
}

with

BrowserBot.prototype.getCurrentWindow = function(doNotModify) {
    ...
    var testWindow = this.currentWindow;
    if (testWindow.wrappedJSObject) {
        testWindow = testWindow.wrappedJSObject;
    }
    ...
}

in the selenium-browserbot.js file. and this worked. I am able to verify my javascript variables in 1.b2 now.

The problem i had with this at first was finding where this file (selenium-browserbot.js) was hiding. But once located and updated. it works like before. all my old tests are passing again in 1.b2.

unpack the selenium-ide.jar file in ...\Application Data\Mozilla\Firefox\Profiles\2rld2d0z.default\extensions\{a6fd85ed-e919-4a43-a5af-8da18bda539f}\chrome and you will see the file under ...\chrome\selenium-ide\content\selenium\scripts

If there are any repercussions to this workaround? please voice them now   

Haw-Bin Chai Master 515 posts since
May 19, 2006
Currently Being Moderated
21. Oct 3, 2008 3:39 PM in response to: byno
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

There's no problem with applying the fix to your IDE installation. The question is how to check this change in ... the contents of the selenium folder are pulled from the Selenium Core project, but making the change there appears to hose Selenium outside of the IDE.

 

If the workaround works for now, great - we'll still need to look for a more permanent solution.

 

 

 

Haw-Bin

David Beginner 7 posts since
Sep 18, 2008
Currently Being Moderated
22. Oct 9, 2008 12:23 PM in response to: byno
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

byno,

 

I've tried your solution but each time I try it I get "Table view is not available with this format"

It looks like there is something wrong with the new jar file, did you see anything like this?

David Beginner 7 posts since
Sep 18, 2008
Currently Being Moderated
23. Oct 9, 2008 12:24 PM in response to: Haw-Bin Chai
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

Haw-Bin,

 

Could a new method be added getUnwrappedCurrentWindow or something, then we could at least get it to work when we needed it to.

 

Thanks, for the help.

Haw-Bin Chai Master 515 posts since
May 19, 2006
Currently Being Moderated
25. Nov 19, 2008 10:10 AM in response to: David Burns
Re: Using Browserbot to call javascript functions not working in Selenium 1b2

I just made a change to Core which seems to do the trick. It adds a getUserWindow() method to browserbot, which should return the unwrapped window in the IDE. E.g.

 

getEval | javascript{ selenium.browserbot.getUserWindow().doWhatever(); }

 

 

 

Haw-Bin

More Like This

  • Retrieving data ...