How to get started with Selenium 2?

I've read here and there that we should now use Selenium 2 (WebDriver if my understanding is right). I'm not talking about Selenium IDE which is really easy to use.

I've read the documentation on Selenium website (which claims not to be complete since Selenium 2 isn't stable, which is fine). My problem is: I can't get starting with Selenium.

I mean, as described, I've downloaded it, launched it. I've found samples test case here and there.

But how do you (with Selenium/WebDriver):

  • start a test/test suite?
  • structure test suites?
  • where do you "put" your tests?
  • Java or PHP for test writing? (I've read that PHP implementation wasn't enough stable for now)
  • Maybe I have missed THE documentation on How this all works?, if so can you point me this out.

    As a side note, I'm an OS X user, even though I think this is not an issue.

    Thanks.


    A proven solution, which I've implemented core concepts at a couple of companies can be found at...

    Conductor framework. I've built this project exclusively for the purpose of open source, and to get people just like you started with selenium 2. The project itself has an apache 2 license, so you are able to take it, and use it in enterprise solutions at your discretion.

    This project includes using the technologies of..

  • Java
  • Eclipse
  • jUnit
  • Maven
  • Selenium 2
  • Git
  • And each piece of software has a role to play.

    Java

    Tests are written in java, and embracing the cross-platform abilities.

    Eclipse

    A proven and widely used IDE solution for Java Developers around the world.

    jUnit

    A unit testing software which runs java unit tests

    Maven

    Arguably the best dependency management and build management software you can have with Java.

    Selenium 2

    The second installment of the Selenium browser automation software, which surpasses Selenium 1 because it ties directly into the browser API, instead of injecting JavaScript.

    Git

    An amazingly easy-to-use (once you're used to it) source control management solution.

    That's it.

    So to your questions. I'm going to put them in the context of the Getting Started with SElenium framework i've provided above.

    start a test/test suite?

    Using jUnit combined with Java, you write your test, then simply right click the method you want to run, and click Run As -> jUnit test and off it goes.

    structure test suites

    If you use jUnit, the only structure that you need, are Classes and Methods. For example...

    /**
     * This tests My Site
     */
    @Config(url="http://example.com", browser=CHROME)
    public class TestMySite extends Locomotive {
    
      @Test
      public void testSomething() {
        click(By.linkText("something"))
        .validateText(By.cssSelector("input"), "something");
      }
    
      @Test
      public void testSomethingElse() {
        check(By.cssSelector("input[type='checkbox']"))
        .validateChecked(By.cssSelector("input[type='checkbox']"));
      }
    }
    

    You are able to run tests individually by running the methods. Additionally, the suites are managed by the class, so you can run the CLASS to run all the methods, and get a nice report afterwards.

    where do you put your tests?

    Per Maven convention, they recommend having a nice and tidy workspace, and test/source architecture. In the getting started project, your projects would be placed in the src/tests/java package, and anywhere within there. You could then schedule your Continuous Integration server to launch a particular package. For example, google. If you wanted to test just the results, then target the results package, and all junit classes found within that package, would be ran.

    Java or PHP for test writing.

    This is all based on preference, and it's always going to be subjective. One thing to keep in mind though... Selenium 2 was coded in java and any other software is a port from other contributors. Ergo, Java is going to be the most up-to-date and stable.


    Well Selenium2() WebDriver or Selenium 1.0 does not answer any of the question you posted above.

    Selenium would only let you interact with UI of web application. If you want to be able to configure your test, create suite etc etc then it depends on which language you plan to use with Selenium. For example I use Java hence I could make use of either junit or testng (I prefer testng) Now testng lets me create suite, decide what is a test, what should not be executed during test run, test reporting and much more.

    I suppose there is some thing called php unit (I have never worked with php) which should be able to answer your question.

    nb you question does not belong to tag "selenium rc". you may like to remove it.


    This is the documentation page I was missing:

    http://seleniumhq.org/docs/05_selenium_rc.html

    链接地址: http://www.djcxy.com/p/53528.html

    上一篇: 如何使用Pandas中的apply来并行化许多(模糊)字符串比较?

    下一篇: 如何开始使用Selenium 2?