Groovy 用geb上传文件

Groovy 用geb上传文件,groovy,selenium-webdriver,geb,Groovy,Selenium Webdriver,Geb,全部! 我想上传我的测试文件。写下它是如何制作的,但它对我不起作用 我有一个领域: <input id="bla-bl-bla" type="file" name="foo-foo-foo"> Geb:0.9.0-RC-1 Groovy:2.1.1 浏览者:FF 19 谢谢大家!

全部! 我想上传我的测试文件。写下它是如何制作的,但它对我不起作用

我有一个领域:

<input id="bla-bl-bla" type="file" name="foo-foo-foo">
Geb:0.9.0-RC-1 Groovy:2.1.1 浏览者:FF 19


谢谢大家!
def "choose banner format"() {
given:
    String file_1 = "/full/path/to/file"
    String uploadfile = "foo-foo-foo"
when: 
    //if j_id83 and j_id91 are integers, caste them to strings!
    $("select", name: Const.namespaceId.toString() + "createBanner:j_id83:j_id91")
    waitFor(25, 2) { $("input", name : Const.namespaceId + "createBanner:upload:j_id256")}
    $("input", id : "name") << name_banner
    $("input").uploadfile  =  banner
    $("input", name : "bar-bar-bar").click()
    waitFor{ $("input", name : "save") }
    def createActLink = $("input", name : "save")
    createActLink.click()
then:
    waitFor{
      // choose an element to refresh on page after input is clicked   
    } 
def“选择横幅格式”(){
鉴于:
字符串file_1=“/full/path/to/file”
String uploadfile=“foo foo foo”
什么时候:
//如果j_id83和j_id91是整数,将它们转换为字符串!
$(“选择”,名称:Const.namespaceId.toString()+“createBanner:j_id83:j_id91”)
waitFor(25,2){$(“输入”,名称:Const.namespaceId+“createBanner:upload:j_id256”)}

$(“输入”,id:“名称”)测试的完整代码是什么?@tim_yates我更新了我的帖子。
then:
块用于断言测试成功完成,我想你需要另一个
和:
块,或者把所有代码放在
when:
块中。你似乎没有测试任何东西是否成功。请参阅“when and then blocks”部分k,如果我把代码放到另一个块,这个代码开始工作?@tim_yates我把这个代码移到
和:
但是我有一个错误
groovy.lang.MissingPropertyException:没有这样的属性:在geb.navigator.NoneEmptyNavigator.NoneEmptyNavigator.propertyMissing(NoneEmptyNavigator.groovy:442)
    def "choose banner format"() {
    when: "choose fake format"
        $("select", name: Const.namespaceId + "createBanner:j_id83:j_id91")
    and: "wait load"
        waitFor(25, 2) { $("input", name : Const.namespaceId + "createBanner:upload:j_id256")}
    then: "can upload file"
        $("input", id : "name") << name_banner
        String file_1 = "/full/path/to/file"
        String uploadfile = "foo-foo-foo"
        $("input").uploadfile  =  banner
        $("input", name : "bar-bar-bar").click()
        def createActLink = $("input", name : "save")
        createActLink.click()
        sleep 20000
}
Expected a condition, but found an assignment. Did you intend to write '==' ?
def "choose banner format"() {
given:
    String file_1 = "/full/path/to/file"
    String uploadfile = "foo-foo-foo"
when: 
    //if j_id83 and j_id91 are integers, caste them to strings!
    $("select", name: Const.namespaceId.toString() + "createBanner:j_id83:j_id91")
    waitFor(25, 2) { $("input", name : Const.namespaceId + "createBanner:upload:j_id256")}
    $("input", id : "name") << name_banner
    $("input").uploadfile  =  banner
    $("input", name : "bar-bar-bar").click()
    waitFor{ $("input", name : "save") }
    def createActLink = $("input", name : "save")
    createActLink.click()
then:
    waitFor{
      // choose an element to refresh on page after input is clicked   
    }