agent/browser/ie/pagetest/PagetestReporting.cpp
/*-----------------------------------------------------------------------------
	Save out the HTML of the page
-----------------------------------------------------------------------------*/
Save out the HTML of the page
Save out the HTML of the page
void CPagetestReporting::SaveHTML()
{
	if( !htmlFile.IsEmpty() )
	{
		if( !html.IsEmpty() )
		{
			HANDLE hFile = CreateFile(htmlFile + _T("_page.html"), GENERIC_WRITE, 0, &nullDacl, CREATE_ALWAYS, 0, 0);
			if( hFile != INVALID_HANDLE_VALUE )
			{
				DWORD bytes;
				WriteFile(hFile, (LPCSTR)html, html.GetLength(), &bytes, 0);
				CloseHandle(hFile);
			}
		}
		CComPtr<IWebBrowser2>	browser;
		POSITION pos = browsers.GetHeadPosition();
		while(pos)
		{
			CBrowserTracker tracker = browsers.GetNext(pos);
			if( tracker.browser && tracker.threadId == GetCurrentThreadId())
				browser = tracker.browser;
		}
		if( browser )
		{
			CComPtr<IDispatch> spDoc;
			if( SUCCEEDED(browser->get_Document(&spDoc)) && spDoc )
			{
				CComQIPtr<IHTMLDocument2> doc = spDoc;
				CComPtr<IHTMLElement> body;
				if( doc && SUCCEEDED(doc->get_body(&body)) && body )
				{
					CComPtr<IHTMLElement> parent;
					if( SUCCEEDED(body->get_parentElement(&parent)) && parent )
					{
						_bstr_t text;
						parent->get_outerHTML(text.GetAddress());
						CStringA bodyText = CT2A(text);
						HANDLE hFile = CreateFile(htmlFile + _T("_dom.html"), GENERIC_WRITE, 0, &nullDacl, CREATE_ALWAYS, 0, 0);
						if( hFile != INVALID_HANDLE_VALUE )
						{
							DWORD bytes;
							WriteFile(hFile, (LPCSTR)bodyText, bodyText.GetLength(), &bytes, 0);
							CloseHandle(hFile);
						}
					}
				}
			}
		}
	}
}
void CPagetestReporting :: SaveHTML ( ) { if ( ! htmlFile . IsEmpty ( ) ) { if ( ! html . IsEmpty ( ) ) { HANDLE hFile = CreateFile ( htmlFile + _T ( " " ) , GENERIC_WRITE , 0 , & nullDacl , CREATE_ALWAYS , 0 , 0 ) ; if ( hFile != INVALID_HANDLE_VALUE ) { DWORD bytes ; WriteFile ( hFile , ( LPCSTR ) html , html . GetLength ( ) , & bytes , 0 ) ; CloseHandle ( hFile ) ; } } CComPtr < IWebBrowser2 > browser ; POSITION pos = browsers . GetHeadPosition ( ) ; while ( pos ) { CBrowserTracker tracker = browsers . GetNext ( pos ) ; if ( tracker . browser && tracker . threadId == GetCurrentThreadId ( ) ) browser = tracker . browser ; } if ( browser ) { CComPtr < IDispatch > spDoc ; if ( SUCCEEDED ( browser -> get_Document ( & spDoc ) ) && spDoc ) { CComQIPtr < IHTMLDocument2 > doc = spDoc ; CComPtr < IHTMLElement > body ; if ( doc && SUCCEEDED ( doc -> get_body ( & body ) ) && body ) { CComPtr < IHTMLElement > parent ; if ( SUCCEEDED ( body -> get_parentElement ( & parent ) ) && parent ) { _bstr_t text ; parent -> get_outerHTML ( text . GetAddress ( ) ) ; CStringA bodyText = CT2A ( text ) ; HANDLE hFile = CreateFile ( htmlFile + _T ( " " ) , GENERIC_WRITE , 0 , & nullDacl , CREATE_ALWAYS , 0 , 0 ) ; if ( hFile != INVALID_HANDLE_VALUE ) { DWORD bytes ; WriteFile ( hFile , ( LPCSTR ) bodyText , bodyText . GetLength ( ) , & bytes , 0 ) ; CloseHandle ( hFile ) ; } } } } } } }
Save out the HTML of the page
Save out the HTML of the page
// save out the base page html
 // save out the DOM
