如何使用getEval()来验证硒变量将typeof [英] How to use getEval() to verify the typeof of a variable in selenium

查看:188
本文介绍了如何使用getEval()来验证硒变量将typeof的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想这样做的硒:
var变量。=编辑;
如果(typeof运算(变量)==未定义){};

但我不完全知道如何与getEval()方法做到这一点。

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.

推荐答案

既然你没有提到的地方编辑就要从我会认为这是在页面上。 VAR赢= this.browserbot.getUserWindow(); 会给你访问窗口

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赢= this.browserbot.getUserWindow(); var变量。= win.editors; typeof运算(变量)===未定义;);

* 从注释编辑的*

*Edit from comment*

browserbot是硒使用以控制浏览器的内部的JavaScript对象。它是控制窗口的对象。您可以在硒做些什么,你可以做BrowserMob。因此,进入你的脚本的高级脚本,然后把

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

这篇关于如何使用getEval()来验证硒变量将typeof的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆