String tempPage = currentHtmlPage.getUrl().toString(); //HtmlPage class window = null; window = new WebWindow(); currentHtmlPage = new WebWindow.getWebClient().getPage(tempPage); //HtmlPage class
private WebResponse getCurrentFrame( WebWindow window, FrameSelector pageFrame ) { return window.hasFrame( pageFrame ) ? window.getFrameContents( pageFrame ) : window.getCurrentPage(); }
FrameSelector findFrame( String target ) { for (int i = 0; i < _openWindows.size(); i++) { WebWindow webWindow = (WebWindow) _openWindows.get( i ); FrameSelector frame = webWindow.getFrame( target ); if (frame != null) return frame; } return null; }
void updateFrameContents( WebWindow requestWindow, String requestTarget, WebResponse response, RequestContext requestContext ) throws IOException, SAXException { if (response.getFrame() == FrameSelector.NEW_FRAME) { WebWindow window = new WebWindow( this, requestWindow.getCurrentPage() ); if (!WebRequest.NEW_WINDOW.equalsIgnoreCase( requestTarget )) window.setName( requestTarget ); response.setFrame( window.getTopFrame() ); window.updateFrameContents( response, requestContext ); _openWindows.add( window ); reportWindowOpened( window ); } else if (response.getFrame().getWindow() != null && response.getFrame().getWindow() != requestWindow) { response.getFrame().getWindow().updateFrameContents( response, requestContext ); } else { if (response.getFrame() == FrameSelector.TOP_FRAME) response.setFrame( requestWindow.getTopFrame() ); requestWindow.updateFrameContents( response, requestContext ); } }
/** * Updates this web client based on a received response. This includes updating * cookies and frames. **/ WebResponse updateWindow( String requestTarget, WebResponse response, RequestContext requestContext ) throws IOException, SAXException { _client.updateClient( response ); if (getClient().getClientProperties().isAutoRefresh() && response.getRefreshRequest() != null) { WebRequest request=response.getRefreshRequest(); WebResponse result=getResponse( request ); return result; } else if (shouldFollowRedirect( response )) { delay( HttpUnitOptions.getRedirectDelay() ); return getResponse( new RedirectWebRequest( response ) ); } else { _client.updateFrameContents( this, requestTarget, response, requestContext ); return response; } }
/** * Returns the value of the named property. Will return null if the property does not exist. **/ public Object get( String propertyName ) { if (propertyName.equals( "name" )) { return getName(); } else if (propertyName.equalsIgnoreCase( "top" )) { return _window.getFrameContents( WebRequest.TOP_FRAME ).getScriptableObject(); } else if (propertyName.equalsIgnoreCase( "parent" )) { return _window.getParentFrameContents( _frame ).getScriptableObject(); } else if (propertyName.equalsIgnoreCase( "opener" )) { return getFrameName().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; } else if (propertyName.equalsIgnoreCase( "closed" )) { return (getFrameName().equals( WebRequest.TOP_FRAME ) && _window.isClosed()) ? Boolean.TRUE : Boolean.FALSE; } else { try { return getSubframeContents( propertyName ).getScriptableObject(); } catch (NoSuchFrameException e) { return super.get( propertyName ); } } }
FrameHolder( WebWindow window ) { _window = window; _topFrame = FrameSelector.newTopFrame( window ); DefaultWebResponse blankResponse = new DefaultWebResponse( window.getClient(), null, WebResponse.BLANK_HTML ); _contents.put( _topFrame, blankResponse ); HttpUnitOptions.getScriptingEngine().associate( blankResponse ); }
final WebResponse response = getSubframeResponse( request, requestContext ); requestContext.runScripts(); result = response == null ? null : response.getWindow().getFrameContents( response.getFrame() ); // javascript might replace the response in its frame } finally { if (null != request && request.equals(_initialRequest)) {
public WebWindow getOpenWindow( String name ) { if (name == null || name.length() == 0) return null; for (Iterator i = _openWindows.iterator(); i.hasNext();) { WebWindow window = (WebWindow) i.next(); if (name.equals( window.getName() )) return window; } return null; }
/** * Returns the response associated with the specified frame name in the main window. * Throws a runtime exception if no matching frame is defined. * * @since 1.6 **/ public WebResponse getFrameContents( FrameSelector targetFrame ) { return _mainWindow.getFrameContents( targetFrame ); }
/** * Returns the response representing the current top page in the main window. */ public WebResponse getCurrentPage() { return _mainWindow.getCurrentPage(); }
/** * Returns the name of the currently active frames in the main window. **/ public String[] getFrameNames() { return _mainWindow.getFrameNames(); }
public void close() { if (getFrameName().equals( WebRequest.TOP_FRAME )) _window.close(); }
void updateFrameContents( WebWindow requestWindow, String requestTarget, WebResponse response, RequestContext requestContext ) throws IOException, SAXException { if (response.getFrame() == FrameSelector.NEW_FRAME) { WebWindow window = new WebWindow( this, requestWindow.getCurrentPage() ); if (!WebRequest.NEW_WINDOW.equalsIgnoreCase( requestTarget )) window.setName( requestTarget ); response.setFrame( window.getTopFrame() ); window.updateFrameContents( response, requestContext ); _openWindows.add( window ); reportWindowOpened( window ); } else if (response.getFrame().getWindow() != null && response.getFrame().getWindow() != requestWindow) { response.getFrame().getWindow().updateFrameContents( response, requestContext ); } else { if (response.getFrame() == FrameSelector.TOP_FRAME) response.setFrame( requestWindow.getTopFrame() ); requestWindow.updateFrameContents( response, requestContext ); } }
/** * Updates this web client based on a received response. This includes updating * cookies and frames. **/ WebResponse updateWindow( String requestTarget, WebResponse response, RequestContext requestContext ) throws IOException, SAXException { _client.updateClient( response ); if (getClient().getClientProperties().isAutoRefresh() && response.getRefreshRequest() != null) { WebRequest request=response.getRefreshRequest(); WebResponse result=getResponse( request ); return result; } else if (shouldFollowRedirect( response )) { delay( HttpUnitOptions.getRedirectDelay() ); return getResponse( new RedirectWebRequest( response ) ); } else { _client.updateFrameContents( this, requestTarget, response, requestContext ); return response; } }
/** * Returns the value of the named property. Will return null if the property does not exist. **/ public Object get( String propertyName ) { if (propertyName.equals( "name" )) { return getName(); } else if (propertyName.equalsIgnoreCase( "top" )) { return _window.getFrameContents( WebRequest.TOP_FRAME ).getScriptableObject(); } else if (propertyName.equalsIgnoreCase( "parent" )) { return _window.getParentFrameContents( _frame ).getScriptableObject(); } else if (propertyName.equalsIgnoreCase( "opener" )) { return getFrameName().equals( WebRequest.TOP_FRAME ) ? getScriptable( _window.getOpener() ) : null; } else if (propertyName.equalsIgnoreCase( "closed" )) { return (getFrameName().equals( WebRequest.TOP_FRAME ) && _window.isClosed()) ? Boolean.TRUE : Boolean.FALSE; } else { try { return getSubframeContents( propertyName ).getScriptableObject(); } catch (NoSuchFrameException e) { return super.get( propertyName ); } } }
FrameHolder( WebWindow window ) { _window = window; _topFrame = FrameSelector.newTopFrame( window ); DefaultWebResponse blankResponse = new DefaultWebResponse( window.getClient(), null, WebResponse.BLANK_HTML ); _contents.put( _topFrame, blankResponse ); HttpUnitOptions.getScriptingEngine().associate( blankResponse ); }
final WebResponse response = getSubframeResponse( request, requestContext ); requestContext.runScripts(); result = response == null ? null : response.getWindow().getFrameContents( response.getFrame() ); // javascript might replace the response in its frame } finally { if (null != request && request.equals(_initialRequest)) {
public WebWindow getOpenWindow( String name ) { if (name == null || name.length() == 0) return null; for (Iterator i = _openWindows.iterator(); i.hasNext();) { WebWindow window = (WebWindow) i.next(); if (name.equals( window.getName() )) return window; } return null; }
/** * Returns the response associated with the specified frame name in the main window. * Throws a runtime exception if no matching frame is defined. **/ public WebResponse getFrameContents( String frameName ) { return _mainWindow.getFrameContents( frameName ); }