Author: kwright
Date: Sun Mar 19 18:21:56 2017
New Revision: 1787649

URL: http://svn.apache.org/viewvc?rev=1787649&view=rev
Log:
Change how test driver is kicked off so that we can specify the language etc.

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=1787649&r1=1787648&r2=1787649&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
 Sun Mar 19 18:21:56 2017
@@ -27,7 +27,7 @@ import java.io.*;
 import java.util.*;
 import org.junit.*;
 
-//import org.apache.manifoldcf.core.tests.HTMLTester;
+import org.apache.manifoldcf.core.tests.SeleniumTester;
 import org.openqa.selenium.By;
 
 /** Basic UI navigation tests */
@@ -40,7 +40,7 @@ public class NavigationHSQLDBUI extends
   {
     // Q: How can we control locale?  Is that even possible?  Will the test 
fail
     // if the browser locale is wrong?
-    testerInstance.gotoUrl("http://localhost:8346/mcf-crawler-ui/index.jsp";);
+    testerInstance.start(SeleniumTester.BrowserType.CHROME, "en-US", 
"http://localhost:8346/mcf-crawler-ui/index.jsp";);
 
     //Login
     testerInstance.waitForElementWithName("loginform");

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=1787649&r1=1787648&r2=1787649&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
 Sun Mar 19 18:21:56 2017
@@ -41,9 +41,13 @@ import java.io.IOException;
 
 public class SeleniumTester {
 
-  protected WebDriver driver;
-  protected WebDriverWait wait;
+  protected WebDriver driver = null;
+  protected WebDriverWait wait = null;
 
+  public enum BrowserType {
+    CHROME
+  };
+  
   /** Constructor. Create a test sequence object. */
   public SeleniumTester() {}
 
@@ -53,30 +57,32 @@ public class SeleniumTester {
    */
   @Before
   public void setup() throws Exception {
+    driver = null;
+    wait = null;
+  }
 
+  public void start(final BrowserType browserType, final String language, 
final String startURL) {
     //Download Chrome Driver for Linux from here 
(https://chromedriver.storage.googleapis.com/index.html?path=2.28/)
-    String driverType = "chrome";
-
-    if (driverType == "chrome") {
-
-      if (System.getProperty("webdriver.chrome.driver") == null ||
-        System.getProperty("webdriver.chrome.driver").length() == 0)
-        throw new Exception("Please configure your SL_CHROME_DRIVER 
environment variable to point to the Selenium Google Chrome Driver");
-
-      //Create a new instance of Chrome driver
-      ChromeOptions options = new ChromeOptions();
-      options.addArguments("--start-maximized");
-      driver = new ChromeDriver(options);
+    switch (browserType) {
+      case CHROME:
 
-    } else {
-      // Create a new instance of the html unit driver
-      //driver = new HtmlUnitDriver(BrowserVersion.CHROME);
-      //((HtmlUnitDriver)driver).setJavascriptEnabled(true);
+        if (System.getProperty("webdriver.chrome.driver") == null ||
+          System.getProperty("webdriver.chrome.driver").length() == 0)
+          throw new IllegalStateException("Please configure your 
SL_CHROME_DRIVER environment variable to point to the Selenium Google Chrome 
Driver");
+
+        //Create a new instance of Chrome driver
+        ChromeOptions options = new ChromeOptions();
+        options.addArguments("--start-maximized", "--lang=" + language);
+        driver = new ChromeDriver(options);
+        break;
+      default:
+        throw new IllegalArgumentException("Unknown browser type");
     }
 
     wait = new WebDriverWait(driver, 10);
+    driver.get(startURL);
   }
-
+  
   public WebDriver getDriver() {
     return driver;
   }
@@ -309,6 +315,7 @@ public class SeleniumTester {
       driver.close();
       driver.quit();
       driver = null;
+      wait = null;
     }
   }
 }
\ No newline at end of file


Reply via email to