使用 ruby​​ 检查下拉菜单中的所有元素是否都存在于硒测试中?

发布于 2024-08-31 01:20:02 字数 336 浏览 5 评论 0原文

您好,

如何使用硒测试检查我创建的数组中的所有元素是否都存在于下拉菜单中?

我有类似的东西,但似乎不起作用

ANIMALS = ["snake","cat","dog"]

def validate_all_animals_exist(selenium)

  ANIMALS.each { |animal| assert selenium.is_element_present(animal), "Expected category [#{animal}] to be present" }

end

提前感谢

HI

how can i check if all elements in an array i created are present in a drop down menu using selenium testing?

i have something like this but dosent seem to work

ANIMALS = ["snake","cat","dog"]

def validate_all_animals_exist(selenium)

  ANIMALS.each { |animal| assert selenium.is_element_present(animal), "Expected category [#{animal}] to be present" }

end

thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

蹲墙角沉默 2024-09-07 01:20:02

您需要使用 verifySelectOptions 调用

验证选择选项(选择定位器,
模式)生成自
获取选择选项(选择定位器)
参数:

 * selectLocator - 标识下拉菜单的元素定位器

返回:
    指定选择下拉列表中所有选项标签的数组

获取指定选择下拉列表中的所有选项标签。

所以会这样

assert_equal "123123", page.get_select_options("foo").join(",")

You need to use the verifySelectOptions call

verifySelectOptions(selectLocator,
pattern) Generated from
getSelectOptions(selectLocator)
Arguments:

    * selectLocator - an element locator identifying a drop-down menu

Returns:
    an array of all option labels in the specified select drop-down

Gets all option labels in the specified select drop-down.

So it would be

assert_equal "123123", page.get_select_options("foo").join(",")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文