package me.alb_i986.selenium.tinafw.sample.tests;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import me.alb_i986.selenium.tinafw.domain.User;
import me.alb_i986.selenium.tinafw.sample.tasks.*;
import me.alb_i986.selenium.tinafw.tasks.*;
import static me.alb_i986.selenium.tinafw.tasks.BDDWebTask.*;

public class SampleWebTest {

	private User user;
	
	@Before
	public void before() {
		user = new User();
		user.openBrowser();
	}
	

	@Test
	public void testSearch() {
		user.doTask(
			new BDDWebTask(
				given(
					new OnMyAboutMePage()
				),
				when(
					new Search()
						.forQuery("paolo")
				),
				then(
					new CanCompliment()
						.theGuy(2)
						.with("love")
				)
			)
		);
	}
	
	@Test
	public void testMyPage() {
		user.doTask(
			new BDDWebTask(
				given(
					new OnMyAboutMePage()
				),
				null,
				then(
					new VerifyBio()
						.matches(".*Genuinely driven by Passion.*"),
					new VerifySocialIcons()
						.isDisplayed("github")
						.isDisplayed("linkedin")
				)
			)
		);
	}
	
	@After
	public void after() {
		user.closeBrowser();
	}
	
}

package me.alb_i986.selenium.tinafw.sample.tests;

import org.junit.Test;

import me.alb_i986.selenium.tinafw.domain.User;
import me.alb_i986.selenium.tinafw.sample.tasks.*;
import me.alb_i986.selenium.tinafw.tasks.*;
import me.alb_i986.selenium.tinafw.tests.JunitWebTest;
import static me.alb_i986.selenium.tinafw.tasks.BDDWebTask.*;

public class SampleWebTest extends JunitWebTest {

	private User user;
	
	@Override
	public void before() {
		super.before();
		user = new User();
		browserManager.registerBrowsers(user.getBrowser());
		user.openBrowser();
	}
	

	@Test
	public void testSearch() {
		user.doTask(
			new BDDWebTask(
				given(
					new OnMyAboutMePage()
				),
				when(
					new Search()
						.forQuery("paolo")
				),
				then(
					new CanCompliment()
						.theGuy(2)
						.with("love")
				)
			)
		);
	}
	
	@Test
	public void testMyPage() {
		user.doTask(
			new BDDWebTask(
				given(
					new OnMyAboutMePage()
				),
				null,
				then(
					new VerifyBio()
						.matches(".*Genuinely driven by Passion.*"),
					new VerifySocialIcons()
						.isDisplayed("github")
						.isDisplayed("linkedin")
				)
			)
		);
	}
	
}

update SampleWebTest to use JunitWebTest