1

私はWatirの世界では初めてです。私の問題は簡単だと思っていましたが、それを成し遂げることができませんでした。

これが私のコードです:

 names = Hash.new
 names[:text] = 'Image'
 puts names
 browser.a("#{names}").click

このエラーが発生しています:

'extract_selector': expected Hash or (:how, 'what'), got ["{:text=>\"Image\"}"]   (ArgumentError)

printとして正しい値を示しています"{:text=>"Image"}"

4

2 に答える 2

2

エラー メッセージを注意深く読むと、*'extract_selector': expected Hash or (:how, 'what')*

これを試して :

browser.a(:text => 'Image').click
           :how     :what

次に実行します(OPのコメントによる)

browser.a(names).click
           Hash

完全なコードは次のとおりです。

require 'watir-webdriver'

b = Watir::Browser.new
b.goto "http://en.wikipedia.org/wiki/Ruby_(programming_language)"
# <a href="/wiki/Just-in-time_compilation" title="Just-in-time compilation">just-in-time compilation</a>
hsh = {:text => 'just-in-time compilation'}
b.a(hsh).text # => "just-in-time compilation"
于 2013-10-10T17:39:08.007 に答える