1 | package br.gov.serpro.expresso.cte.common; |
---|
2 | |
---|
3 | import org.openqa.selenium.WebDriver; |
---|
4 | import org.openqa.selenium.firefox.FirefoxDriver; |
---|
5 | import org.openqa.selenium.support.PageFactory; |
---|
6 | import org.testng.annotations.AfterClass; |
---|
7 | import org.testng.annotations.BeforeClass; |
---|
8 | |
---|
9 | import br.gov.serpro.expresso.cte.pages.common.LoginPage; |
---|
10 | import br.gov.serpro.expresso.cte.pages.common.PreferencesPage; |
---|
11 | |
---|
12 | /** |
---|
13 | * @author L.F.Estivalet (Serpro) |
---|
14 | * |
---|
15 | * Created on Jan 4, 2011 at 3:53:19 PM |
---|
16 | * |
---|
17 | */ |
---|
18 | public class BaseTestCase implements Constants { |
---|
19 | protected WebDriver driver; |
---|
20 | |
---|
21 | @BeforeClass |
---|
22 | public void beforeClass() { |
---|
23 | driver = new FirefoxDriver(); |
---|
24 | driver.get(URL); |
---|
25 | } |
---|
26 | |
---|
27 | public void login() { |
---|
28 | LoginPage page = PageFactory.initElements(driver, LoginPage.class); |
---|
29 | page.login(USER, PASS); |
---|
30 | } |
---|
31 | |
---|
32 | public PreferencesPage openPreferencesPage() { |
---|
33 | driver.get(URL_PREFERENCES); |
---|
34 | return PageFactory.initElements(driver, PreferencesPage.class); |
---|
35 | } |
---|
36 | |
---|
37 | @AfterClass |
---|
38 | public void afterClass() { |
---|
39 | driver.close(); |
---|
40 | } |
---|
41 | |
---|
42 | /** |
---|
43 | * TODO Rever esse metodo. Foi o unico jeito que consegui fazer pegar o |
---|
44 | * numero total de mensagens importantes. O metodo apenas aguarda 5 segundos |
---|
45 | * antes de continuar a execucao. |
---|
46 | * |
---|
47 | * @throws Exception |
---|
48 | * |
---|
49 | * @see br.gov.serpro.cte.email.listar.ListarEmailsImportantesTestCase |
---|
50 | */ |
---|
51 | public void dummyWait() throws Exception { |
---|
52 | dummyWait(5); |
---|
53 | } |
---|
54 | |
---|
55 | /** |
---|
56 | * @param seconds |
---|
57 | * @throws Exception |
---|
58 | */ |
---|
59 | public void dummyWait(int seconds) throws Exception { |
---|
60 | for (int second = 0;; second++) { |
---|
61 | if (second >= seconds) { |
---|
62 | System.out.println("timeout"); |
---|
63 | return; |
---|
64 | } |
---|
65 | Thread.sleep(1000); |
---|
66 | } |
---|
67 | |
---|
68 | } |
---|
69 | |
---|
70 | } |
---|