当前位置: 动力学知识库 > 问答 > 编程问答 >

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.

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.

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:

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. storeElementPresent might be also a useful command. It stores in boolean variable, if specific element is present or not. 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
分享给朋友:
您可能感兴趣的文章:
随机阅读: