Ruby on rails 请参见第6.8.4节

Ruby on rails 请参见第6.8.4节,ruby-on-rails,watir,Ruby On Rails,Watir,这是我使用ruby进行下拉选择的代码: ruby版本是2.4.3 watir版本6.8.4 黄瓜3.01版 firefox版本47 b.select(id: 'curLocation').option(text: 'Chennai').select 此代码对我无效。您使用的是#选择错误。请看更多示例,但您需要做的是: b.select(id: 'curLocation').select('Chennai') 此外,Firefox47不再是受支持的版本。请更新至Firefox的最新

这是我使用ruby进行下拉选择的代码:

ruby版本是2.4.3

watir版本6.8.4

黄瓜3.01版

firefox版本47

b.select(id: 'curLocation').option(text: 'Chennai').select      
此代码对我无效。

您使用的是
#选择错误。请看更多示例,但您需要做的是:

b.select(id: 'curLocation').select('Chennai')
此外,Firefox47不再是受支持的版本。请更新至Firefox的最新版本和最新版本。另外,您的标题是Watir 6.8.4,但您列出了5.1.4,这是不推荐的

require 'watir'

b = Watir::Browser.start 'bit.ly/watir-webdriver-demo'
s = b.select_list id: 'entry_1000001'
s.select'Ruby'
s.selected_options
参考:

举个例子。 我希望它能帮助你

完全正确-您可以使用.option(:xpath,“xpath”)
或者.option(代码:“xpath”)

您能把错误包括进来吗?不,她的语法是正确的。她用了正确的方法
b.select().option().select
是选择该选项的另一个systax。我显示的代码具有额外的等待逻辑,这在这里可能是必需的。Watir 7将区分
#select
#select#u all
,以使其更具性能,但它仍然是语法上受鼓励的签名。您没有提到,您说“您正在使用#select error”。但她使用正确,语法没有问题。
select_from_list = browser.select_list(:xpath, "xpath")
                        .option(:text => opts[:yourjson])
select_from_list.select