简体   繁体   English

Selenium IDE javascript如果存储的变量=是,请单击“元素”

[英]Selenium IDE javascript Click Element if stored variable = Yes

What I want to do is to cause Selenium IDE to click a tick box if a stored value 'x' equals Yes. 我要执行的操作是,如果存储的值“ x”等于“是”,则使Selenium IDE单击一个复选框。

I have tried the below but it advises that Yes is not defined. 我在下面尝试过,但建议未定义“是”。

Also I am unsure which Selenium IDE command to use for this action. 另外,我不确定该操作要使用哪个Selenium IDE命令。

Any help is appreciated :) 任何帮助表示赞赏:)

click|

javascript{if(storedVars['x']==Yes){this.browserbot.findElement('id=includesSlowerTrains').click();}} |

EDIT: WITHOUT EXTENSION: I've tried it on google.com: 编辑:无扩展:我已经在google.com上尝试过:

storeElementPresent id=gbqfbb x
click javascript{if(storedVars['x'] == true){this.browserbot.findElement('id=gbqfbb').click();}}

Try it for yourself :) 自己尝试一下:)

I would suggest using goto_sel_ide extension, available online. 我建议使用在线提供的goto_sel_ide扩展名。 storeElementPresent might be also a useful command. storeElementPresent可能也是有用的命令。 It stores in boolean variable, if specific element is present or not. 如果特定元素存在或不存在,它将存储在boolean变量中。 Try following code: 尝试以下代码:

storeElementPresent tickbox x
gotoIf ${x}==true variableXequalsTrue
gotoIf ${x}==false variableXequalsFalse
label variableXequalsTrue //your script will go right here if element "tickbox" is present
click yourElement
goto afterTickbox
label variableXequalsFalse //your script will go right here if element "tickbox" is NOTpresent
//todo, if element is not present
goto afterTickbox
label afterTickbox

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM