【问题标题】:can't access module elements using geb groovy无法使用 geb groovy 访问模块元素
【发布时间】:2017-08-23 08:02:59
【问题描述】:

我有一个由框架组成的页面。我想访问框架的元素并操纵它们。我想使用模块来实现我的更改。这就是我的代码的样子。

<html>
<body>
    <frame name="header" ></frame>
    <frame name="center" >


        <input name='quantity' type='text'>
        <input name='ok' type='radio' value='ok'>
   </frame>
  <frame name="footer" ></frame>

然后我就有了像这样的 groovy 页面类

class myMainPage extends Page {
   static content = {
       myModule{module FrameModule}
   }
 }


class FrameModule extends Module {
     def FrameElement 
     static content = {
     Myframe { $('frame', name:'center') }
     FrameElement {Myframe.find('input[name="quantity"]')}
     myQuantity = FrameElement.module(TextInput)
     myQuantity.text = '10'
  }

}

我是这样测试的

Then:

   to myMainPage
 and:
     myModule.myQuantity

通过设置我得到的模块

类没有这样的属性TextInput:FrameModule

我如何操作那些框架的元素

【问题讨论】:

标签: groovy automated-tests spock geb


【解决方案1】:

看来你需要导入

import geb.module.TextInput

除非你这样做了,只是没有将它包含在你的帖子中。

实际上,仔细观察,您应该消除您的 FrameElement,而是像下面这样声明 myQuantity。这将消除一些绒毛并将其简化为找到元素并将其实例化为 TextInput 模块的一行。

myQuantity = {$("input", name: "quantity").module(TextInput)}

你应该能够像现在一样做 myModule.myQuantity。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多