[portal-commits] JBoss Portal SVN: r12319 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests: src/org/jboss/portal/test/selenium and 1 other directory.
portal-commits at lists.jboss.org
portal-commits at lists.jboss.org
Fri Nov 28 10:55:22 EST 2008
Author: vrockai
Date: 2008-11-28 10:55:22 -0500 (Fri, 28 Nov 2008)
New Revision: 12319
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml
Log:
more debugging
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-11-28 14:19:15 UTC (rev 12318)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-11-28 15:55:22 UTC (rev 12319)
@@ -35,7 +35,7 @@
public void setupChromeForLogin() throws Exception {
String browser = System.getProperty("browser");
selenium = new JBossSelenium("127.0.0.1", 44444, browser, "http://localhost:8080/portal/");
-
+ JBossSeleniumTestListener.selenium = selenium;
selenium.start();
selenium.setTimeout(PAGE_LOAD);
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java 2008-11-28 14:19:15 UTC (rev 12318)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSelenium.java 2008-11-28 15:55:22 UTC (rev 12319)
@@ -4,7 +4,10 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.SeleniumException;
@@ -19,15 +22,30 @@
super.click(locator);
}
catch (SeleniumException e){
+
+ String name = "E_";
+ Pattern methodname = Pattern.compile("^org.jboss.portal.test.selenium\\S+test\\S+\\(\\S+\\)");
+ for(int i=0;i<e.getStackTrace().length;i++){
+ String input = e.getStackTrace()[i].toString();
+ Matcher match = methodname.matcher(input);
+ if (match.matches()){
+ input = input.replace("org.jboss.portal.test.selenium","");
+ input = input.replaceAll("\\(.*\\)","");
+ name += input;
+ }
+ }
+ name += "."+count;
try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("html"+count+".html")));
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name+".html")));
out.println(getHtmlSource());
out.close();
} catch (IOException e1) {
e1.printStackTrace();
- }
- captureScreenshot("shot"+ count +".jpg");
+ }
+
+ captureScreenshot(name +".jpg");
count++;
+
throw new SeleniumException(e);
}
}
Added: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2008-11-28 15:55:22 UTC (rev 12319)
@@ -0,0 +1,33 @@
+package org.jboss.portal.test.selenium;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import org.testng.ITestResult;
+import org.testng.TestListenerAdapter;
+
+import com.thoughtworks.selenium.Selenium;
+
+public class JBossSeleniumTestListener extends TestListenerAdapter {
+
+ protected static Selenium selenium;
+ protected static int count;
+
+ @Override
+ public void onTestFailure(ITestResult tr) {
+
+ String name = "F_"+tr.getName()+"-" + count ;
+ try {
+ PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".html")));
+ out.println(selenium.getHtmlSource());
+ out.close();
+ } catch (IOException e1) {
+ e1.printStackTrace();
+ }
+ selenium.captureScreenshot(name + ".jpg");
+ count++;
+ }
+
+}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2008-11-28 14:19:15 UTC (rev 12318)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2008-11-28 15:55:22 UTC (rev 12319)
@@ -21,14 +21,13 @@
selenium.click("link=Logout");
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
}
@Test(enabled = true, description = "login as default user 'user' with password 'user'.")
public void testDefaultUserLogin() throws Exception {
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertTrue(selenium.isElementPresent("link=Login"), "Expected DOM element for login link does not exist.");
Assert.assertEquals(selenium.getText("link=Login"), "Login", "Login button doesn't exist.");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml 2008-11-28 14:19:15 UTC (rev 12318)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/testng.xml 2008-11-28 15:55:22 UTC (rev 12319)
@@ -69,8 +69,9 @@
<classes>
<class name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"></class></classes>
</test>
-<!--
+
<listeners>
- <listener class-name="org.testng.reporters.JUnitXMLReporter"></listener></listeners>
--->
+<!-- <listener class-name="org.testng.reporters.JUnitXMLReporter"></listener> -->
+ <listener class-name="org.jboss.portal.test.selenium.JBossSeleniumTestListener"/>
+</listeners>
</suite>
More information about the portal-commits
mailing list