css - 寄存器 0x​​104567911

标签 css ruby xpath cucumber capybara

从下拉列表(自定义)中选择一个值而不是常规下拉列表,它有很多下拉值

我可以用代码选择第一个值

find('.selected', :text=>arg1,exact: false).click

但无法选择剩余的值,因为文本有很多填充空间!如何应对这种情况

最佳答案

我不确定下拉菜单是什么样的,但您可能会做的一件事是收集所有选项:

dropdown = session.find(:css, '#ElementId')                   #customize as needed
options  = dropdown.all(:css, "option").collect {|o| o.text}

然后使用索引从下拉列表中选择:

session.select options[3], from: 'ElementId'

关于css - 寄存器 0x​​104567911,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22556621/

相关文章:

html - 文本和图像缩放不同

html - 如何根据不同的手机屏幕尺寸制作CSS?

html - 彼此相邻的 div,1 : 200px, 2:100%

ruby - 使用 String#end_with?() 但忽略大小写

xpath - 使用 Selenium Webdriver 单击超链接

javascript - getComputedStyle (or) $.css(map) <-- 获取每个样式声明

ruby - 使用 Ruby 按值过滤 JSON 数组

ruby-on-rails - Rails 实例变量在开发中显示,但在 Heroku 中不显示

java - Selenium:使用 CSS 选择器访问部分滚动条

xml - Xpath/XSLT : check if following sibling is a particular node