javascript 如何使用 selenium IDE 自动选择复选框

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13394700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 18:38:08  来源:igfitidea点击:

How to automatically select check box using selenium IDE

javascriptcheckboxselenium-ide

提问by Gunjan

I am trying to create a code that automatically select one of the checkbox among five check boxes. What should I do for it? Is it possible to do so in Selenium IDE. If yes, please share code with me. Is there need to change/ edit in user extensions.js . If I want to create a function in user extensions for handling all check boxes is it possible? Kindly share with me both IDE and user extensions.js code for dealing such condition.

我正在尝试创建一个代码,自动选择五个复选框中的一个复选框。我该怎么做?是否可以在 Selenium IDE 中这样做。如果是,请与我分享代码。是否需要在 user extensions.js 中更改/编辑。如果我想在用户扩展中创建一个函数来处理所有复选框,是否有可能?请与我分享处理这种情况的 IDE 和用户 extensions.js 代码。

回答by Rohit Ware

You can select check box if different ways like mentioned below

如果下面提到的不同方式,您可以选择复选框

1.click  name=abc
2.click  xpath=(//input[@name='vehicle'])
3.click  //input[@type='checkbox']

I hope you are looking for same.

我希望你正在寻找相同的。

回答by Lance Cleveland

How to check a checkbox in Selenium IDE:

如何在 Selenium IDE 中选中复选框:

Force it to ALWAYS be on:

强制它始终开启:

command: check
target: <locator>, id=my_checkbox, name=the_checkbox (or whatever you have)
value:

Force it to always be off:

强制它始终关闭:

command: uncheck
target: <locator>, id=my_checkbox, name=the_checkbox (or whatever you have)
value:

That's it.

而已。

回答by Ankit jain

Yes. You can select the check box through Selenium ide

是的。您可以通过 Selenium ide 选中复选框

command: check
target:  id , name or Xpath of the check box (or whatever you have)
value : 

Second solution, you can used click command

第二种解决方案,您可以使用单击命令

command: Click
target:  id or Xpath of the check box (or whatever you have)
value 

回答by Tam Dao

I can only check at a specific checkbox using "clickAt" command and its Xpath.

我只能使用“clickAt”命令及其 Xpath 检查特定的复选框。