Selenium Server

Pessoal, estou tentando fazer o Selenium Funcionar aki mas estou apanhando e não sei pq!

Olhe o meu código extraido da NET

[code]/*

  • To change this template, choose Tools | Templates
  • and open the template in the editor.
    */

package br.com.zean.daoJPA;

import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import junit.framework.TestCase;
import org.openqa.selenium.server.SeleniumServer;

public class ExampleTest
extends TestCase
{
private static final String MAX_WAIT_TIME_IN_MS = “60000”;
private static final String BASE_URL = “http://localhost:8084/SystemManager/index.jsp”;
private Selenium selenium = new DefaultSelenium( “localhost”,
4444,
“*iexplore”,
BASE_URL);

private SeleniumServer seleniumServer;
public void setUp()
throws Exception
{
seleniumServer = new SeleniumServer();
seleniumServer.setDebugMode(true);

  seleniumServer.start();
  selenium.start();

}

public void tearDown()
throws Exception
{
selenium.stop();
seleniumServer.stop();
}

public void testClickingLink()
throws Exception
{
selenium.open(BASE_URL);
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
String expectedTitle = “System Manager”;
assertEquals(expectedTitle, selenium.getTitle());
}
}
[/code]

Quando mando executar ele abre o IE mas parece que ele muda o endereço…
Alguém sabe o que estou fazendo de errado? Estou utilizando a versão “selenium-remote-control-0.9.2-dist.zip”

[]s


[quote=Thiago Ananias]Pessoal, estou tentando fazer o Selenium Funcionar aki mas estou apanhando e não sei pq!

Olhe o meu código extraido da NET

/* http://localhost:8084/SystemManager/index.jsp"; private Selenium selenium = new DefaultSelenium( "localhost",
Quando mando executar ele abre o IE mas parece que ele muda o endereço…
Alguém sabe o que estou fazendo de errado? Estou utilizando a versão “selenium-remote-control-0.9.2-dist.zip”
[]s
[/quote]

:arrow: Como você obtem os serviços que estão executando por instrumentação existe algum ambiente de monitor, outra coisa o deployment que foi configurado o que pode esta disputando serviço do mesmo endereço localhost seja aplicativo seja em particular outra chamada remota.

A aplicacao esta subindo em Tomcat, Jetty, JBoss ?
Se for JBoss, tanto o Selenium Server como o JBoss sobem por default na porta 4444. Uma solucao eh startar o selenium com -Dport=4443 por exemplo.

Se não for isso, o seleium está abrindo o browser ?
Qual o erro no log ?

Opa pessoal, desculpe a demora!

então, o Selenium abre o IExplore mas aparentemente naum aparece nenhum erro, ele fica parado como se o teste estivesse rodando infinitamente olhem o log:

[quote]20:27:21.640 INFO - Java: Sun Microsystems Inc. 1.6.0_03-b05
20:27:21.640 INFO - OS: Windows XP 5.1 x86
20:27:21.656 INFO - v0.9.2 [2006], with Core v0.8.3 [1879]
20:27:22.171 INFO - Version Jetty/5.1.x
20:27:22.187 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
20:27:22.187 INFO - Started HttpContext[/selenium-server,/selenium-server]
20:27:22.187 INFO - Started HttpContext[/,/]
20:27:22.203 INFO - Started SocketListener on 0.0.0.0:4444
20:27:22.203 INFO - Started org.mortbay.jetty.Server@131f71a
20:27:22.468 INFO - Checking Resource aliases
20:27:22.515 INFO - Command request: getNewBrowserSession[*iexplore, http://localhost:8084/SystemManager] on session null
20:27:23.281 INFO - Launching session 842515
20:27:23.296 WARN - It looks like your baseUrl (http://localhost:8084/SystemManager) is pointing to a file, not a directory (it doesn’t end with a /). We’re going to have to strip off the last part of the pathname.
20:27:23.484 INFO - Modifying registry settings…
20:27:24.015 INFO - Launching Internet Explorer…[/quote]

oq pode ser?

vlw

up

Aqui acho que você tem um problema:

private Selenium selenium = new DefaultSelenium( “localhost”,

4444,

“*iexplore”,

BASE_URL);

Ao criar o cliente, você deve colocar o endereço do servidor onde irá rodar a aplicação, no caso “http://localhost:8084”.
Para abrir uma página, coloque só o que vem depois do servidor (contexto+página), no caso “/SystemManager/index.jsp”

selenium.open("/SystemManager/index.jsp");

Vê se assim funciona.

oi fwbrasil…não funcionou :frowning: ficou na mesma, olha meu codigo como ficou agora

[]s

[code]package br.com.zean.daoJPA;

import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.DefaultSelenium;
import junit.framework.TestCase;
import org.openqa.selenium.server.SeleniumServer;

public class ExampleTest extends TestCase {

private static final String MAX_WAIT_TIME_IN_MS = “60000”;
private Selenium selenium = new DefaultSelenium( “localhost”,
4444,
"*iexplore",
http://localhost:8084”);

private SeleniumServer seleniumServer;
public void setUp() throws Exception {

  seleniumServer = new SeleniumServer();
  seleniumServer.start();
  selenium.start();

}

public void tearDown() throws Exception {
selenium.stop();
seleniumServer.stop();
}

public void testClickingLink() throws Exception {
selenium.open("/SystemManager/index.jsp");
selenium.waitForPageToLoad(MAX_WAIT_TIME_IN_MS);
String expectedTitle = “System Manager”;
assertEquals(expectedTitle, selenium.getTitle());
}

}[/code]

Caramba pessoal isso parece tão ridiculo!! e não estou conseguindo fazer funcionar!! Já estou me sentindo frustrado, alguem ae por favor, me passe algum codigo seu pronto…pode ser um teste como este que tentei fazer do Google…E por favor me fale qual a versão do selenium e do navegador que esta utilizando!

Este código tb não funcionou…

[code]import com.thoughtworks.selenium.;
import junit.framework.
;
import org.openqa.selenium.server.SeleniumServer;

public class GoogleTest extends TestCase {
private Selenium browser;
public void setUp() throws Exception {
SeleniumServer seleniumServer = new SeleniumServer();
browser = new DefaultSelenium(“localhost”,
5555, “*iexplore”, “http://www.google.com”);
seleniumServer.start();
browser.start();
}

public void testGoogle() {
    browser.open("/webhp?hl=en");
    browser.type("q", "hello world");
    browser.click("btnG");
    browser.waitForPageToLoad("5000");
    assertEquals("hello world - Google Search", browser.getTitle());
}

public void tearDown() {
    browser.stop();
}

}
[/code]

[]s

Thiago,

Eu não conheço muito o Selenium pra conseguir te ajudar, mas acho que no seu caso não tem muito o que fazer, acho que você deve largar os códigos prontos e partir pra documentação da ferramenta e descobrir o que está errado.

Selenium Overview

Na própria documentação do Selenium, eles recomendam para os iniciantes começarem com o selenium-ide, que é um plugin do Firefox e permite exportar o teste feito como script em várias linguagens.

Espero que ajude.

Boa sorte,
Roger Leite

Então Roger, eu tenho este Selenium IDE, a ideia dele é preencher os testes…não vou sair programando em Selenium, o problema é configurar o Servidor e fazer o Java chamar os testes

[]s

Estou com o mesmo problema que o seu.
Quero rodar os testes usando o selenium RC.
Qualquer novidade posta ai ou me manda email.

valeu

consegui fazer funcionar um teste simples , seguindo este tutorial

meu codigo

public static void main(String[] args) {

		try {
	    	
	    	int port = 4444;
	        String host = "localhost";
	        String browser = "*firefox";
	        String baseUrl = "http://www.google.com";
	        
	        CommandProcessor command = new HttpCommandProcessor(host, port, browser, baseUrl);
	        DefaultSelenium selenium = new DefaultSelenium(command);
	        selenium.start();

	        selenium.open("http://www.google.com/webhp");
	        selenium.waitForPageToLoad("9000");
	        selenium.type("q", "java na cabeça abril blogs");
	        selenium.click("btnG");
	        selenium.waitForPageToLoad("9000");
	        selenium.click("//div[@id='res']/div/ol/li[1]/h3/a/em[2]");
	        selenium.waitForPageToLoad("9000");

	        System.out.println(selenium.isTextPresent("teste"));
	    } catch (Exception e) {
	       
	        e.printStackTrace();
	    }