使用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_*,由此生成一族函数
一切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
3def store_xpath_count locator, variable_name
4 command 'storeXpathCount',locator, variable_name
5end
6
7def 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
14end
generate_methods中第11行为添加项2
3def store_xpath_count locator, variable_name
4 command 'storeXpathCount',locator, variable_name
5end
6
7def 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
14end
一切OK