我正在开发一个黄瓜,ruby,capybara,siteprism项目,我们在一个siteprism页面对象中定义大多数英国变量。
I'm working on a cucumber, ruby, capybara, siteprism project and we're defining most UK variables in a siteprism page object.
有没有办法使用我创建的siteprism变量作为新变量定义的一部分?
Is there a way for me to use the siteprism variables that I create as part of the definition for new variables?
例如,如果我有一个siteprim页面,如下所示:
For example, if I've got a siteprim page that looks like:
sections :user_container, "#user_container" do sections :address_module, "#address" do element :house_number, "#house_number" end end我可以在同一个pageobject声明中定义新的变量,例如:
Can I somehow define new variables on the same pageobject declaration, something like:
element :postcode, :user_container[2].:address_module[1].text OR element :postcode, ":user_container[2].:address_module[1].text" OR some other syntax or workaround?谢谢。
推荐答案查看节的site_prisms代码 - github/natritmeyer/site_prism/blob/master/lib/site_prism/element_container.rb#L33 - 可以看到所有它做的是在类上定义方法。它不会将传递给它的参数存储在以后可以访问的任何地方或任何用户可访问的变量中。因此,没有办法在其他元素/节调用中重用它们。你可以做的只是在类(页面对象)定义方法你要访问邮政编码,如
From a look at site_prisms code for sections - github/natritmeyer/site_prism/blob/master/lib/site_prism/element_container.rb#L33 - one can see that all it's doing is defining methods on the class. It doesn't store the arguments passed to it anywhere that can be accessed later or in any user accessible variables. So, no there's no way to reuse them in other element/section calls. What you can do is just define methods on the class (page object) where you want to access the postcode like
def postcode user_container[2].address_module[1].text end更多推荐
在定义页面对象时,是否可以使用siteprism变量定义新变量?
发布评论