1

I want to do this in selenium: var variable = editors; if (typeof(variable) == "undefined") {}; but I am not entirely sure how to do it with the getEval() method.

chromedude
  • 4,246
  • 16
  • 65
  • 96
  • 1
    Where did this variable come from? – pnewhook Sep 05 '10 at 00:05
  • @peter.newhook it was defined before but I did not put it in this code, sorry, I will fix that – chromedude Sep 05 '10 at 01:30
  • can you give us an example of what you are trying to do? – AutomatedTester Sep 05 '10 at 14:13
  • I have a var variable which holds a value that is defined above it be a random generator. The variable can hold an array of random numbers or none at all. In the none at all case I have to use an if statement so that it does not do a certain action when there is none at all because it will return an error. When there is none at all it is undefined – chromedude Sep 06 '10 at 12:39

1 Answers1

4

Since you have not mentioned where editors is coming from I am going to assume that it is on the page. var win = this.browserbot.getUserWindow(); will give you access to window.

selenium.getEval("var win = this.browserbot.getUserWindow();var variable = win.editors; typeof ( variable) === 'undefined';");

****Edit from comment****

browserbot is the JavaScript object that Selenium uses to control the internals of the browser. It is the object that controls the window. What you can do in Selenium you can do in BrowserMob. So go into the advanced scripting of your script and then put

 var resultFromEval = selenium.getEval("var win = this.browserbot.getUserWindow();var variable = win.editors; typeof ( variable) === 'undefined';");
AutomatedTester
  • 22,188
  • 7
  • 49
  • 62
  • ok... hmm... do you know how you would do that with browsermob? because I have never seen browserbot before. – chromedude Sep 06 '10 at 22:01