按照维基上的示例查找嵌套元素(https://github.com/cheezy/page-object/wiki/Nested-Elements),我能够在模态中找到项目。
问题是,我需要按索引号选择它们,有没有办法处理这个问题而不使用将功能传递给底层驱动程序的弃用功能?
目前的代码如下。
div(:add_line_modal, :id => 'add-line-modal')
select(:add_line_service_select) do |page|
page.add_line_modal_element.select(:index => 0)
end
抛出此
*** DEPRECATION WARNING
*** You are calling a method named select at %PROJECTDIRECTORY%
*** This method does not exist in page-object so it is being passed to the driver.
*** This feature will be removed in the near future.
*** Please change your code to call the correct page-object method.
*** If you are using functionality that does not exist in page-object please request it be added.
答案 0 :(得分:-1)
对example更加小心。嵌套行不只是“unordered_list”,而是“unordered_list_element”。
如果要在访问者外部描述元素,则应添加“_element”:
# accessor
link('ok', text: 'ok')
# outside accessor
def ok
link_element(text: 'ok')
end
在您的示例中,您应该使用:
page.add_line_modal_element.select_list_element(:index => 0)