Code Monkey home page Code Monkey logo

seleniumframework's Introduction

Introduction

The test automation framework currently uses Selenium to create automated web browsing tests. For more background on Selenium, please check out http://seleniumhq.org/.

Project Clone:

Source: git clone https://[email protected]/davidzheng1022/automation_framework.git
Wiki: https://bitbucket.org/davidzheng1022/automation_framework/wiki

Features

  • Automatically takes screenshot
  • Automatically close browser
  • Multiple running

  • Spring + JUnit4 based project
  • Supports local or Grid Running
  • Annotation used, decouple the code
  • PageFactory introduced

Quick Start

  1. Download the code and run 'mvn install'

  2. Create a maven project

  3. Add the dependency to your project pom file

    <dependency>
        <groupId>com.hj.selenium.framework</groupId>
        <artifactId>selenium-framework</artifactId>
        <version>1.0.0</version>
    </dependency>

4.Create a 'Page' that extends PageContext

#!java

public class PacteraPage extends PageContext
{
	@FindBy(id = "s")
	private WebElement input;

	@FindBy(id = "searchsubmit")
	private WebElement button;

	/**
	 * type the text and search
	 *
	 * @param text
	 */
	public void seach(String text)
	{
		input.sendKeys(text);
		button.click();
	}

5.Create your test class that extends AbstractSelenium

#!java

//@SeleniumConfig("selenium.properties")
@TargetURL("http://www.pactera.com")
public class PacteraPageTest extends AbstractSelenium
{
	@Page
	private PacteraPage pacteraPage;

	@Test
	public void testSearch() {

		pacteraPage.seach("david");
		String result = pacteraPage.getFirstSearchResult();
		Assert.isTrue(StringUtils.containsIgnoreCase(result, "david1"), "The result:'"+ result+ "' does not contain any 'david' key words.");
	}
}

Advanced

You can put @SeleniumConfig("selenium.properties") on the class or method to customised your test scripts. More options defined in the selenium.properties

#running on 'single' mode or 'grid' mode, default value 'single mode'
gridMode=false

#provide the hub url if running on 'grid' mode
hub=http://localhost:4444/wd/hub

#choose your browser among ie/firefox/chrome
browser=firefox

#set the selenium timeout value(seconds), default is 30s
timeout=40

#enable the proxy, default is 'false'
proxyEnable = true

#set the proxy url
#e.g. http://xxx.com/proxy.pac, http://xxx.com:8080
proxyURL = 

#set the directory to store the screen shots, default folder is under your project.
screenshotsDir = /Users/David/Documents/pics

#default is 'false'
screenRecorderEnable = false

#set the directory to store the recording, default folder is under your project.
screenRecorderDir = /Users/David/Documents/recording

#Next Relase

  • Recording function
  • DB(refactor)
  • Email function
  • PDF function
  • ....

#Reference

Selenium: http://seleniumhq.org/
Junit: http://junit.org/
SpringJunit4: http://docs.spring.io/spring-batch/reference/html/testing.html

#About Author

seleniumframework's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.