使用selenium-on-rails的一些讨论 3]assertXpathCount的使用
3.assertXpathCount的使用
xpath_count一族的函数
assertXpathCount
storeXpathCount
...
会发现在selenium-on-rails中并没有对应函数assert_xpath_count等
原因是selenium-on-rails所用的selenium-core好像版本不够...没有assert_xpath_count
首先需要更新selenium-core,下载最新的,把core文件夹下的东西全部覆盖到selenium-core就可以
然后需要添加函数
分析doc,发现selenium-on-rails所有断言函数的原型是store_*,由此生成一族函数
For each store_foo there‘s assert_foo, assert_not_foo, verify_foo, verify_not_foo, wait_for_foo, wait_for_not_foo.
做出如下修改
一切OK
xpath_count一族的函数
assertXpathCount
storeXpathCount
...
会发现在selenium-on-rails中并没有对应函数assert_xpath_count等
原因是selenium-on-rails所用的selenium-core好像版本不够...没有assert_xpath_count
首先需要更新selenium-core,下载最新的,把core文件夹下的东西全部覆盖到selenium-core就可以
然后需要添加函数
分析doc,发现selenium-on-rails所有断言函数的原型是store_*,由此生成一族函数
For each store_foo there‘s assert_foo, assert_not_foo, verify_foo, verify_not_foo, wait_for_foo, wait_for_not_foo. 1
#selenium-on-rails/lib/selenium-on-rails/test_builder_accessors.rb
2
3
def store_xpath_count locator, variable_name
4
command 'storeXpathCount',locator, variable_name
5
end
6
7
def self.generate_methods
8

9
'store_whether_this_frame_match_frame_expression',
10
'store_whether_this_window_match_window_expression',
11
'store_xpath_count' ## tachikoma added
12
each_assertion method do |assertion_method, command_name|
13

14
end
generate_methods中第11行为添加项
#selenium-on-rails/lib/selenium-on-rails/test_builder_accessors.rb2

3
def store_xpath_count locator, variable_name4
command 'storeXpathCount',locator, variable_name5
end6

7
def self.generate_methods8

9
'store_whether_this_frame_match_frame_expression',10
'store_whether_this_window_match_window_expression',11
'store_xpath_count' ## tachikoma added12
each_assertion method do |assertion_method, command_name|13

14
end一切OK


浙公网安备 33010602011771号