Testes em Aplicações Vaadin com Selenium

0 respostas
K

E ai pessoal

Estou desenvolvendo uma aplicação utilizando o Vaadin e queria automatizar os testes utilizando o Selenium, estou utilizando o Maven para o build,
mais estou enfrentando um grande problema, quando mando executar os testes eles funcionam corretamente somente se a aplicação ja esteja rodando
em algum servidor (Estou utilizando o Jetty), pois caso não esteja rodando da erro 404, gostaria de saber se existe alguma outra maneira de realizar os testes
sem ter a necessidade de startar o server antes e fazer o deploy, alguma maneira programatica que eu possa resolver esse problema, pois irei colocar esse projeto
em integração continua. Segue um pequeno exemplo do meu código de testes.

Valew

public class TestCase1 {

    private WebDriver driver;
    private String baseUrl;
    private StringBuffer verificationErrors = new StringBuffer();
    @Before
    public void setUp() throws Exception {
        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("webdriver.firefox.bin", "C:\\firefox\\firefox.exe");
        driver = new FirefoxDriver(new FirefoxBinary(new File("C:\\firefox\\firefox.exe")), profile);
        baseUrl = "http://localhost:8080";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void test1() throws Exception {
        driver.get(baseUrl + "/ProjectVaadin/");
        //driver.findElement(By.cssSelector("#buttontest > span.v-button-wrap > span.v-button-caption")).click();
        driver.findElement(By.xpath("//div[@id='ProjectVaadin-414429684']/div/div[2]/div/div/div/div/div/div[2]/div/div/span/span")).click();
        assertEquals("Help",driver.findElement(By.cssSelector("#buttontest > span.v-button-wrap > span.v-button-caption")).getText() );
    }

    @Test
    public void test2() throws Exception {
        driver.get(baseUrl + "/ProjectVaadin/");
        //driver.findElement(By.cssSelector("#buttontest > span.v-button-wrap > span.v-button-caption")).click();
        //driver.findElement(By.xpath("//div[@id='ProjectVaadin-414429684']/div/div[2]/div/div/div/div/div/div[2]/div/div/span/span")).click();
        assertEquals("Helpxx",driver.findElement(By.cssSelector("#buttontest > span.v-button-wrap > span.v-button-caption")).getText() );
    }

    @After
    public void tearDown() throws Exception {
        driver.quit();
        String verificationErrorString = verificationErrors.toString();
        if (!"".equals(verificationErrorString)) {
            //fail(verificationErrorString);
        }
    }

    private boolean isElementPresent(By by) {
        try {
            driver.findElement(by);
            return true;
        } catch (NoSuchElementException e) {
            return false;
        }
    }
Criado 26 de setembro de 2012
Respostas 0
Participantes 1