1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
import junit.framework.TestCase;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleneseTestCase;
import java.util.regex.Pattern;
public class TextAndDocsParameterTest extends SeleneseTestCase {
protected DefaultSelenium createSeleniumClient(String url) throws Exception {
return new DefaultSelenium("localhost", 4444, "*firefox", url);
}
public void setUp() throws Exception {
selenium=createSeleniumClient("http://localhost:6969/");
selenium.start();
}
public void tearDown() throws Exception {
selenium.stop();
}
protected boolean isCaptureScreetShotOnFailure() {return true;}
public void testTextAndDocument() throws Exception {
selenium.open("test-site/test/HtmlTextAndDocsParameterRenderer.faces");
assertTrue(selenium.isElementPresent("parameterTestForm:edit:comment"));
assertTrue(selenium.isTextPresent("Obvious textgoogle (be)google (com)google (uk)"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:add"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:0:delete"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:1:delete"));
verifyTrue(selenium.isElementPresent("parameterTestForm:edit:2:delete"));
assertEquals("google (be)", selenium.getText("link=google (be)"));
assertTrue(selenium.isElementPresent("link=Modifier ce document"));
assertTrue(selenium.isElementPresent("link=google (com)"));
assertTrue(selenium.isElementPresent("//a[@onclick=\"if (showBlock('parameterTestForm:edit:1:edit')) removeElementContent('parameterTestForm:edit:1:show'); return false;\"]"));
assertTrue(selenium.isElementPresent("link=google (uk)"));
assertTrue(selenium.isElementPresent("//a[@onclick=\"if (showBlock('parameterTestForm:edit:2:edit')) removeElementContent('parameterTestForm:edit:2:show'); return false;\"]"));
selenium.type("parameterTestForm:edit:comment", "text and document test");
selenium.click("parameterTestForm:edit:add");
assertTrue(selenium.isElementPresent("parameterTestForm:edit:3:name"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:3:uploadedDocument"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:3:uploadedDocument"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:3:update"));
assertTrue(selenium.isTextPresent("Nom"));
assertTrue(selenium.isTextPresent("Envoyer un fichier"));
assertTrue(selenium.isTextPresent("Type de document"));
assertTrue(selenium.isElementPresent("document.parameterTestForm.elements['parameterTestForm:edit:3:DocumentType'][1]"));
assertTrue(selenium.isElementPresent("parameterTestForm:edit:3:DocumentType"));
assertTrue(selenium.isElementPresent("document.parameterTestForm.elements['parameterTestForm:edit:3:DocumentType'][2]"));
}
} |
Partager