Commits

Bob Swift committed 3c6fccc

GINT-46: wait parameter cannot be null. Set to default if null comes in.

Comments (0)

Files changed (1)

src/main/groovy/org/swift/tools/SeleniumHelper.groovy

 import java.util.Map
 
 import org.codehaus.gant.GantBinding
-import org.openqa.selenium.*
+import org.openqa.selenium.By
+import org.openqa.selenium.NoSuchElementException
+import org.openqa.selenium.OutputType
+import org.openqa.selenium.TakesScreenshot
+import org.openqa.selenium.TimeoutException
+import org.openqa.selenium.WebDriver
 import org.openqa.selenium.chrome.ChromeDriver
 import org.openqa.selenium.firefox.FirefoxDriver
 import org.openqa.selenium.ie.InternetExplorerDriver
     protected Helper helper
     protected WebDriver driver
     protected String browser
-    protected Map findDefaultParameters = [wait: 10]
+    protected Map findDefaultParameters = [wait: DEFAULT_WAIT]
     protected Integer delay // standard delay parameter to help view selenium scripts as the run
+    static protected DEFAULT_WAIT = 10 // seconds
     static protected DEFAULT_SLEEP = 200 // milliseconds - some intermittent failures if things go too fast
 
     /**
      */
     public def findElement(final Map inParameters) {
         def parameters = findDefaultParameters + inParameters
+        parameters.wait = parameters.wait ?: DEFAULT_WAIT  // can't be null if used
+        //helper.logWithFormat("find parameters", parameters)
         def element = null
         def byMethod = getByMethod(parameters)
         boolean success = byMethod != null
                     if ((parameters.debug == true) && (parameters.multiple != true)) {
                         helper.logWithFormat 'found element', [element: element, tag: element?.getTagName(), text: element?.getText(), isDisplayed: element.isDisplayed(), isEnabled: element.isEnabled(), isSelected: element.isSelected()]
                     }
-                } catch (org.openqa.selenium.NoSuchElementException exception) {
+                } catch (NoSuchElementException exception) {
                     message 'error', getFindElementErrorMessage(parameters)
                 } catch (Exception exception) {
                     message 'error', "Unexpected findElement exception: ${exception}"