How to use getEval() to verify the typeof of a variable in selenium

筅森魡賤 提交于 2019-12-13 18:13:53

问题


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.


回答1:


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';");


来源:https://stackoverflow.com/questions/3644461/how-to-use-geteval-to-verify-the-typeof-of-a-variable-in-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!