Sample time diff:
With jq:
real 0m1.666s
user 0m0.262s
sys 0m0.290s
With Python json.tool:
real 0m2.217s
user 0m0.492s
sys 0m0.539s
Useful links:
Summary of my Development and QA Automation work experiences and list useful links/articles of development, automation regression, and load test etc.
import requests from lxml import html pageContent=requests.get('https://en.wikipedia.org/wiki/List_of_Olympic_medalists_in_judo') tree = html.fromstring(pageContent.content) goldWinners=tree.xpath('//*[@id="mw-content-text"]/table/tr/td[2]/a[1]/text()') silverWinners=tree.xpath('//*[@id="mw-content-text"]/table/tr/td[3]/a[1]/text()') #bronzeWinner we need rows where there's no rowspan - note XPath bronzeWinners=tree.xpath('//*[@id="mw-content-text"]/table/tr/td[not(@rowspan=2)]/a[1]/text()') medalWinners=goldWinners+silverWinners+bronzeWinners medalTotals={} for name in medalWinners: if medalTotals.has_key(name): medalTotals[name]=medalTotals[name]+1 else: medalTotals[name]=1 for result in sorted( medalTotals.items(), key=lambda x:x[1],reverse=True): print '%s:%s' % result
"Note: Your aim should not be to implement a certain pattern in your framework. Instead, identify a problem in the framework and then recognize the pattern which could be used to solve the problem. Do not use any design pattern where it is not really required!!"
Normally IBM RFT just regards all objects in Win domain without respect that the AUT is a Java application.It's fine normally, but for some special objects (e.g. grid) against which you'd like call the special methods for your test purpose, you could enable RFT to treat objects in Java domain:
OCR which might be the last choice for identify object/text in screen in TestComplete.
Open OCR sample at,
C:\Program Files\Automated QA\TestComplete 5\Samples\Scripts\OCR\OCR.pjs
Just run it.
There are 2 parts of code, but below is the key point,
TextToFind = "E-mail";
Pic = wOfficeListBox.Picture(0, 0, wOfficeListBox.Width, wOfficeListBox.Height, false);
OCRObjList = OCR.CreateObject(Pic);
FindRes = OCRObjList.FindRectByText(TextToFind);
The only part you need to replace is Pic = wOfficeListBox.Picture(0, 0, wOfficeListBox.Width, wOfficeListBox.Height, false);
You could use the way in this sample if you could get the object, otherwise you could always use Sys.Desktop.ActiveWindow() to get the window snapshot and specify the coordinates of the area you care, and do the OCR, the recognition speed is good.
And check TestComplete Help for topic “Recognition Tips” to know which area is better for your case.
1. Method to identify big page
var childNum = doc.ChildCount;
if (childNum > 13000 || childNum == 0) {
Log.Warning("Can not handle too large page!");
return null;
}
2. Release no use memory for browser and TestComplete
Based on information at,
minimize then maximize window could force process to release the no used memory, code for IE is as below:
// to release memory of browser
var browerWindow = windowPage.Parent;
while (! BuiltIn.IsSupported(browerWindow, "Minimize")) {
browerWindow = browerWindow.Parent;
}
browerWindow.Minimize();
browerWindow.Restore();
// to release memory of TC
Sys.Process("TestComplete").Window("TfrmTCMainForm", "*", 1).Activate();
Sys.Process("TestComplete").Window("TfrmTCMainForm", "*", 1).Minimize();
Sys.Process("TestComplete").Window("TfrmTCMainForm", "*", 1).Maximize();
you could do above at your threshold by checking Sys.Process("TestComplete").MemUsage
But for FireFox, to release the memory, we are not lucky. We have to use task manager to minimize and maximize it. In addition, we also have to turn on MSAA and hard code like below,
function _releaseFFMemory()
{
var p1;
var w1;
var w2;
p1 = Sys.Process("Explorer");
p1.Window("Shell_TrayWnd").Window("Button", "start").btn_Start.Click();
p1.Window("DV2ControlHost", "Start Menu").Window("DesktopSFTBarHost", "", 2).Window("SysListView32").mi_Run.Click();
p1.Window("#32770", "Run").Window("ComboBox").Window("Edit").Keys("taskmgr[Enter]");
p1 = Sys.Process("taskmgr");
w1 = p1.Window("#32770", "Windows Task Manager");
w2 = w1.Window("SysTabControl32", "Tab1");
w2.ClickTab("Applications");
w2 = w1.Window("#32770", "", 1).Window("SysListView32", "Tasks").list_item_Bookie_Home_Page_Mozilla_Firefox;
w2.ClickR();
p1.Window("#32768").mi_Minimize.Click();
w2.ClickR();
p1.Window("#32768").mi_Maximize.Click();
w1.title_bar.btn_Close.Click();
}
3. Use as little memory as possible
Tips from the same message board and my experiences,
1) Log message only when needed;
2) Turn on auto-save log: Options | Engines | Log and set the auto-save interval. This will flush the log to disk every x number of minutes. (better performance, not sure if help reduce memory usage)
3) Store screenshots in PNG format instead of BMP format.
4) Call the Log.LockEvents method to prevent TestComplete from posting event messages; And call Log.UnlockEvents when you need it. If you never care event messages even when you got warning or error, use Log.LockEvents(0).
By checking HTTPSampler2 source code which is for HTTPClient HttpSampler in package org.apache.jmeter.protocol.http.sampler, we could find more checks/controls than normal HttpSampler in same package. Even we don’t care the detailsJ
Conclusion: use HTTPClient HttpSampler but not normal one. They have the exact same GUI.