@Override public void open(String url) { String targetURL = ""; if (url.startsWith("/")) { targetURL = TestPropsValues.PORTAL_URL + url; } else { targetURL = url; } for (int second = 0; ; second++) { if (second >= TestPropsValues.TIMEOUT_IMPLICIT_WAIT) { BaseTestCase.fail("Timeout: unable to open url \"" + targetURL + "\""); } try { get(targetURL); if (TestPropsValues.BROWSER_TYPE.equals("*iehta") || TestPropsValues.BROWSER_TYPE.equals("*iexplore")) { refresh(); } if (targetURL.equals(getLocation())) { break; } Thread.sleep(1000); } catch (Exception e) { } } }
@Override public void selectWindow(String windowID) { Set<String> windowHandles = getWindowHandles(); if (windowID.equals("name=undefined")) { String title = getTitle(); for (String windowHandle : windowHandles) { WebDriver.TargetLocator targetLocator = switchTo(); targetLocator.window(windowHandle); if (!title.equals(getTitle())) { return; } } BaseTestCase.fail("Unable to find the window ID \"" + windowID + "\""); } else if (windowID.equals("null")) { WebDriver.TargetLocator targetLocator = switchTo(); targetLocator.window(_defaultWindowHandle); } else { String targetWindowTitle = windowID; if (targetWindowTitle.startsWith("title=")) { targetWindowTitle = targetWindowTitle.substring(6); } for (String windowHandle : windowHandles) { WebDriver.TargetLocator targetLocator = switchTo(); targetLocator.window(windowHandle); if (targetWindowTitle.equals(getTitle())) { return; } } BaseTestCase.fail("Unable to find the window ID \"" + windowID + "\""); } }
@Override public void waitForPopUp(String windowID, String timeout) { int wait = 0; if (timeout.equals("")) { wait = 30; } else { wait = GetterUtil.getInteger(timeout) / 1000; } if (windowID.equals("") || windowID.equals("null")) { for (int i = 0; i <= wait; i++) { Set<String> windowHandles = getWindowHandles(); if (windowHandles.size() > 1) { return; } try { Thread.sleep(1000); } catch (Exception e) { } } } else { String targetWindowTitle = windowID; if (targetWindowTitle.startsWith("title=")) { targetWindowTitle = targetWindowTitle.substring(6); } for (int i = 0; i <= wait; i++) { for (String windowHandle : getWindowHandles()) { WebDriver.TargetLocator targetLocator = switchTo(); targetLocator.window(windowHandle); if (targetWindowTitle.equals(getTitle())) { targetLocator.window(_defaultWindowHandle); return; } } try { Thread.sleep(1000); } catch (Exception e) { } } } BaseTestCase.fail("Unable to find the window ID \"" + windowID + "\""); }
public void logError(Method method, Object[] arguments) { StringBundler sb = new StringBundler(); sb.append("<font color=\"red\">"); sb.append("Command failure <b>"); sb.append(method.getName()); sb.append("</b>"); if (arguments != null) { if (arguments.length == 1) { sb.append(" with parameter "); } else if (arguments.length > 1) { sb.append(" with parameters "); } for (Object argument : arguments) { sb.append("<b>"); sb.append(String.valueOf(argument)); sb.append("</b> "); } } log(sb.toString()); sb = new StringBundler(); sb.append("Command failure "); sb.append(method.getName()); if (arguments != null) { if (arguments.length == 1) { sb.append(" with parameter "); } else if (arguments.length > 1) { sb.append(" with parameters "); } for (Object argument : arguments) { sb.append(String.valueOf(argument)); sb.append(" "); } } BaseTestCase.fail(sb.toString()); }