Cheezy Dynamic Finder for Page Section

冷暖自知 提交于 2019-12-24 20:15:50

问题


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?


回答1:


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 .

That said, you could use the internal platform object's #page_for and #pages_for methods. The parameters are:

  • A Hash for locating the container elements.
  • The page section class.

Example:

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


来源:https://stackoverflow.com/questions/59164940/cheezy-dynamic-finder-for-page-section

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!