Author: kwright
Date: Tue Mar 21 07:31:59 2017
New Revision: 1787904

URL: http://svn.apache.org/viewvc?rev=1787904&view=rev
Log:
More SeleniumTester API revisions

Modified:
    
manifoldcf/branches/CONNECTORS-1196-2/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/NavigationHSQLDBUI.java
    
manifoldcf/branches/CONNECTORS-1196-2/framework/core/src/test/java/org/apache/manifoldcf/core/tests/SeleniumTester.java

Modified: 
manifoldcf/branches/CONNECTORS-1196-2/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/NavigationHSQLDBUI.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1196-2/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/NavigationHSQLDBUI.java?rev=1787904&r1=1787903&r2=1787904&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1196-2/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/NavigationHSQLDBUI.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1196-2/connectors/rss/connector/src/test/java/org/apache/manifoldcf/crawler/connectors/rss/tests/NavigationHSQLDBUI.java
 Tue Mar 21 07:31:59 2017
@@ -161,8 +161,8 @@ public class NavigationHSQLDBUI extends
     /* Can't do this because we wind up crawling CNN and that's not allowed 
for a test like this.
     
     //Start the job
-    testerInstance.performJobAction(jobID,"Start minimal");
-    testerInstance.waitForJobStatus(jobID,"Done",120);
+    testerInstance.performJobActionEN(jobID,"Start minimal");
+    testerInstance.waitForJobStatusEN(jobID,"Done",120);
     */
     
     //Navigate to List Jobs
@@ -175,7 +175,7 @@ public class NavigationHSQLDBUI extends
     testerInstance.verifyThereIsNoError();
 
     //Wait for the job to go away
-    testerInstance.waitForJobDelete(jobID, 120);
+    testerInstance.waitForJobDeleteEN(jobID, 120);
 
     // Delete the repository connection
     testerInstance.navigateTo("List repository connections");

Modified: 
manifoldcf/branches/CONNECTORS-1196-2/framework/core/src/test/java/org/apache/manifoldcf/core/tests/SeleniumTester.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1196-2/framework/core/src/test/java/org/apache/manifoldcf/core/tests/SeleniumTester.java?rev=1787904&r1=1787903&r2=1787904&view=diff
==============================================================================
--- 
manifoldcf/branches/CONNECTORS-1196-2/framework/core/src/test/java/org/apache/manifoldcf/core/tests/SeleniumTester.java
 (original)
+++ 
manifoldcf/branches/CONNECTORS-1196-2/framework/core/src/test/java/org/apache/manifoldcf/core/tests/SeleniumTester.java
 Tue Mar 21 07:31:59 2017
@@ -401,11 +401,11 @@ public class SeleniumTester
   // Macro operations for job management
   
   /**
-   * Perform an action (Start, Start minimal, Pause, Restart, Restart minimal, 
Abort) on a specified job.
+   * Perform an action (Start, Start minimal, Pause, Restart, Restart minimal, 
Abort) on a specified job (English version).
    * @param jobID
    * @param action
    */
-  public void performJobAction(String jobID, String action)
+  public void performJobActionEN(String jobID, String action)
   {
     //Navigate to Status and Job management
     navigateTo("Manage jobs");
@@ -415,17 +415,33 @@ public class SeleniumTester
   }
   
   /**
-   * Wait until the status of an job become as mentioned
-   * @param jobID
-   * @param jobStatus
-   * @param timeoutAmount
+   * Wait until the status of an job become as mentioned (English version)
+   * @param jobID is the jobID
+   * @param jobStatus is the desired job status (e.g. 'Done')
+   * @param timeoutAmount is the maximum time until the status is expected
+   * @throws Exception
+   */
+  public void waitForJobStatusEN(final String jobID, final String jobStatus, 
final int timeoutAmount) throws Exception
+  {
+    waitForJobStatus(jobID, jobStatus, timeoutAmount, "Manage jobs", 
"liststatuses", "Refresh");
+  }
+  
+  /**
+   * Wait until the status of an job become as mentioned (generic version)
+   * @param jobID is the jobID
+   * @param jobStatus is the desired job status (e.g. 'Done')
+   * @param timeoutAmount is the maximum time until the status is expected
+   * @param manageJobsPage is the 'manage jobs' page
+   * @param listStatusesElement is the 'list statuses' element
+   * @param refreshButton is the 'Refresh" button
    * @throws Exception
    */
-  public String waitForJobStatus(String jobID, String jobStatus, int 
timeoutAmount) throws Exception
+  public void waitForJobStatus(final String jobID, final String jobStatus, int 
timeoutAmount, final String manageJobsPage, final String listStatusesElement, 
final String refreshButton)
+    throws Exception
   {
     //Navigate to Status and Job management
-    navigateTo("Manage jobs");
-    waitForElementWithName("liststatuses");
+    navigateTo(manageJobsPage);
+    waitForElementWithName(listStatusesElement);
 
     while (true)
     {
@@ -441,39 +457,77 @@ public class SeleniumTester
       {
         throw new Exception("Timed out waiting for job " + jobID + " to 
acheive status '" + jobStatus + "'");
       }
-      clickButton("Refresh");
-      waitForElementWithName("liststatuses");
+      clickButton(refreshButton);
+      waitForElementWithName(listStatusesElement);
       //Let us wait for a second.
       Thread.sleep(1000L);
       timeoutAmount--;
     }
-    return getJobStatus(jobID);
   }
 
-  public String getJobStatus(String jobID)
+  /** Obtain a given job's status (English version).
+   * @param jobID is the job ID.
+   * @return the job status, if found,
+   */
+  public String getJobStatusEN(final String jobID) throws Exception
+  {
+    return getJobStatus(jobID, "Manage jobs", "liststatuses");
+  }
+  
+  /** Obtain a given job's status (generic version).
+   * @param jobID is the job ID.
+   * @param manageJobsPage is the 'manage jobs' page
+   * @param listStatusesElement is the 'list statuses' element
+   * @return the job status, if found,
+   */
+  public String getJobStatus(final String jobID, final String manageJobsPage, 
final String listStatusesElement)
+    throws Exception
   {
-    WebElement element = 
driver.findElement(By.xpath("//tr[@job-id="+jobID+"]"));
+    //Navigate to Status and Job management
+    navigateTo(manageJobsPage);
+    waitForElementWithName(listStatusesElement);
+
+    final WebElement element = 
driver.findElement(By.xpath("//tr[@job-id="+jobID+"]"));
+    if (element == null)
+    {
+      throw new Exception("Can't find job "+jobID);
+    }
     return element.getAttribute("job-status-name");
   }
 
   /**
-   * Wait for a specified job to go away after being deleted.
+   * Wait for a specified job to go away after being deleted (English version).
    * @param jobID
    * @param timeoutAmount
    * @throws Exception
    */
-  public void waitForJobDelete(final String jobID, int timeoutAmount) throws 
Exception
+  public void waitForJobDeleteEN(final String jobID, int timeoutAmount) throws 
Exception
   {
-    navigateTo("Manage jobs");
-    waitForElementWithName("liststatuses");
+    waitForJobDelete(jobID, timeoutAmount, "Manage jobs", "liststatuses", 
"Refresh");
+  }
+  
+  /**
+   * Wait for a specified job to go away after being deleted (generic version).
+   * @param jobID
+   * @param timeoutAmount
+   * @param manageJobsPage is the 'manage jobs' page
+   * @param listStatusesElement is the 'list statuses' element
+   * @param refreshButton is the 'Refresh" button
+   * @throws Exception
+   */
+  public void waitForJobDelete(final String jobID, int timeoutAmount, final 
String manageJobsPage, final String listStatusesElement, final String 
refreshButton)
+    throws Exception
+  {
+    navigateTo(manageJobsPage);
+    waitForElementWithName(listStatusesElement);
     while (exists(By.xpath("//tr[@job-id=\"" + jobID + "\"]")))
     {
       if (timeoutAmount == 0)
       {
         throw new Exception("Timed out waiting for job "+jobID+" to go away");
       }
-      clickButton("Refresh");
-      waitForElementWithName("liststatuses");
+      clickButton(refreshButton);
+      waitForElementWithName(listStatusesElement);
       //Let us wait for a second.
       Thread.sleep(1000L);
       timeoutAmount--;


Reply via email to