网页部分的Cheezy Dynamic Finder [英] Cheezy Dynamic Finder for Page Section
问题描述
我正在使用cheezy的page-object-gem来使用ruby.在在此给出了一个很好的答案之后,我决定问这个问题(page_section
不是我认为的要素).无论如何,page_section
和page_sections
的动态查找器/定位器的语法是什么?
I'm on ruby using the page-object-gem by cheezy. Following the excellent answer here, I decided to ask this question (a page_section
isn't an element I think). Anyway what is the syntax for the dynamic finder/locator for a page_section
and page_sections
?
推荐答案
我不认为此方案是在原始设计中考虑的,因此没有太大的支持.随时在 https://github.com/cheezy/page-object/issues .
I do not believe this scenario was considered in the original design, so there is not great support. Feel free to request it at https://github.com/cheezy/page-object/issues .
也就是说,您可以使用内部platform
对象的#page_for
和#pages_for
方法.参数为:
That said, you could use the internal platform
object's #page_for
and #pages_for
methods. The parameters are:
- 用于定位容器元素的哈希.
- 页面板块类.
示例:
class Container
include PageObject
end
class MyPage
include PageObject
# Individual page section
def container
platform.page_for({tag_name: 'div'}, Container)
end
# Collection of page sections
def containers
platform.pages_for({tag_name: 'div'}, Container)
end
end
这篇关于网页部分的Cheezy Dynamic Finder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!