学习创业板和斯波克 [英] Learning GEB and Spock

查看:183
本文介绍了学习创业板和斯波克的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是一个手动测试人员努力学习GEB和斯波克。要了解这些干什么我必须有java或者常规的先验知识?我一直在阅读创业板的书,什么是prerequisites,书籍或学习资源?请帮忙。谢谢你。

I am a manual tester trying to learn GEB and Spock. To learn these do I have to have prior knowledge of java or groovy? I have been reading the book of GEB, What are the prerequisites, books or learning resources? Please help. Thanks.

推荐答案

我试过编译一些要领和一些'好对富人',我发现非常有帮助,当我拿起创业板

I tried compiling some essentials and some 'good-to-haves' that I found very helpful when I picked up Geb.


  1. 魔术。最重要的是,你需要学习的Groovy覆盖本手册中,但由于显而易见的原因,如果你迷恋你可能要考虑的Groovy语言在行动的。虽然不需要的Java拿起Groovy中,如果你是从Java(除闭包),甚至是Python的背景下,你也许可以通过教程15分钟,脱脂,你在那里的话)。

  1. Some Groovy Magic. Most of all that you need to learn Groovy is covered in this manual but for obvious reasons if you get obsessed with the language you might want to consider Groovy in Action. While Java is not needed to pick up Groovy, If you are from a Java (except for closures) or even a Python background, you could probably skim through the tutorial for 15 minutes and you are there already).

一个小硒。越多,越好,但不要害怕,这单页告诉你所有你需要知道的关于硒的webdriver你一般会使用。但要强调,多多益善。

A little Selenium. The more, the better but fear not, this single page tells you all that you need to know about the Selenium Webdriver that you would generally use. But to stress, the more the better.

jQuery选择器(大家说,这是容易的,但坦率地说,我指的是手工至少两次每小时。我是哑巴,所以...)。如果你是新来的jQuery,你会想从基本选择开始,然后点击左侧导航菜单更多。请注意,并非所有的jQuery选择适用于盖布盖布,但教程的选择部分不是很详尽,引人入胜。

jQuery selectors (everybody says that it is easy but frankly, I refer to the manual at least twice per hour. I am dumb, so…). If you are new to jQuery, you would want to start from basic selectors and click on the left navigation menu for more. Please note that not all jQuery selectors are applicable for Geb but the selectors section of Geb tutorial wasn't very exhaustive and engaging.

在我的测试用例结束后,我需要生成横跨多个测试用例绵延幻想的报告,我有测试用例之间的依赖关系。所以,我去href=\"http://testng.org/doc/index.html\">的TestNG的而不是斯波克的

At the end of my testcases, I need to generate a fanciful report which stretches across multiple testcases and I had dependencies among testcases. So, I went for TestNG instead of Spock. Frankly, I didn't give Spock a lot of chance.

PageObjects 其实不是盖布,但PageObjects一个prerequisite如此真棒,你从来不想去想它外面盖布。 PageObjects是一个可爱的小图案它说,你换你的HTML页面的结构为对象,以使实际测试不必处理。哈。得了你。让我把,在简单的英语。

PageObjects is actually not a prerequisite for Geb but PageObjects are so awesome that you never wanted to think about Geb outside of it. PageObjects is a cute little pattern which says that you wrap the structure of your HTML page into an Object so that the actual test does not have to deal with it. Hah. Got you. Let me put that in plain English.

我说,你有哪些具有nametext的ID输入文本框登记表。你将如何获得文本框的手柄?在DOM而言,在JavaScript中,你会只是做一个

Say, you have a registration form with input textbox which has an id of "nametext". How would you get the handle of the textbox? In DOM terms, in javascript, you would just do a

 document.getElementById("nametext")

在硒,你会做一个非常类似的事情。

In Selenium, you would do a very similar thing

 driver.findElement(By.id("nametext"))

所以,如果你想填充杰森在硒文本框,你会做

So, if you would want to populate Jason in your text box in Selenium, you would do a

driver.findElement(By.id("nametext")).sendKeys("Jason"); 

如果你这样做,你所有的输入字段,很快你的测试用例变得丑陋可恨。取而代之的是,在面向对象而言,您封装。您创建一个新的类,比如 RegistrationPage 和包装你的 findElement 的SendKeys 如:

If you do that for all your input fields, very soon your testcases become ugly and hateful. Instead of that, in OO terms, you encapsulate. You create a new class, say RegistrationPage and wrap your findElement and sendKeys as in :

public class RegistrationPage{

    …

    public RegistrationPage fillRegistrationForm(String name, String email){

        driver.findElement(By.id("nametext")).sendKeys(name); 
        driver.findElement(By.id("emailtext")).sendKeys(email); 

    }

}

和从你的测试用例,你会说

and from your testcase, you would say

  RegistrationPage regPage=new RegistrationPage();
  regPage.fillRegistrationForm("Jason","jason@bourne.com");

(甚至更好的想法是包裹你的输入值到一个类,并把它传递给fillRegistrationForm)

事实上,盖布利用了一个更好的方法PageObjects - jQuery选择救援

In fact, Geb leverages PageObjects in a much better way - jQuery selectors to the rescue

class InputFormPage extends Page{

    …

    static content={
        name {$("input", id:"entry_0")}
        emailAddress {$("input", id:"entry_1")}
    }
 }

和在你的测试用例,你刚才说

and in your testcase, you would just say

 name.value ("Jason")
 emailAddress.value ("jason@bourne.com")

这篇关于学习创业板和斯波克的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆