PMC:QA:Improve sales order POC with Sahi document3
In document PMC:QA:Improve sales order POC with Sahi document2,we talked about ZkwebuiIDGenerator.
IDGenerator has been intergrated with latest Adempiere version by Carlos Ruiz.I tested.
Contents
Info
- Adempiere reversion:12417 20100527,this version has been integrated with IDGenerator by Carlos Ruiz
- sahi:20100430
- browser:Chrome 4.0.266.0
POC
test scripts
scripts are recorded by sahi controller
- first need to configure your browser to use sahi server and port as its proxy.
- then start sahi server
my test works well in Chrome
- first open http://localhost:9999/_s_/spr/launch.htm
- then input http://adempiereservername:port/webui
- a sahi controller window appear,close it
- open a sahi controller window by CTRL-ALT-DblClick on the page
- now you can fill script name and push Record
but my test can't work in firefox(3.5.6),redirect to timeout page.
Carlos Ruiz tried and it worked immediately.More please view: .http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3697238
login.sah:login adempiere
_setValue(_textbox("zk_comp_6"), "SuperUser"); _setValue(_password("zk_comp_20"), "System"); _click(_image("zk_comp_73!hvig")); _click(_image("spacer.gif")); _click(_cell("GardenWorld Admin")); _click(_image("zk_comp_137!hvig"))
soorder_create.sah:create a sales order
first time record | second time record | description |
---|---|---|
_click(_link("Sales Order")); | _click(_link("Sales Order")); | link "Sales order" |
_click(_image("zk_comp_2319!hvig")); | _click(_image("zk_comp_2319!hvig")); | image "New24.png" to create a new record |
_click(_image("spacer.gif[2]")); | _click(_image("spacer.gif[2]")); | |
_click(_cell("HQ")); | _click(_cell("HQ")); | Organization |
_click(_image("spacer.gif[3]")); | _click(_image("spacer.gif[3]")); | |
_click(_cell("POS Order")); | _click(_cell("POS Order")); | Target document type |
_click(_image("zk_comp_2432!hvig")); | _click(_image("zk_comp_2432!hvig")); | Business partner image |
_click(_image("zk_comp_3132!hvig")); | _click(_image("zk_comp_3132!hvig")); | Refresh button "Refresh24.png" |
_click(_radio("zk_comp_3160!cm")); | _click(_radio("zk_comp_3160!cm")); | select bpartner |
_click(_image("zk_comp_3138!hvig")); | _click(_image("zk_comp_3138!hvig")); | Ok button "Ok24.png" |
_click(_image("spacer.gif[14]")); | _click(_image("spacer.gif[14]")); | |
_click(_cell("HQ Warehouse")); | _click(_cell("HQ Warehouse")); | |
_click(_image("spacer.gif[26]")); | _click(_image("spacer.gif[26]")); | |
_click(_cell("GardenAdmin")); | _click(_cell("GardenAdmin")); | |
_click(_image("zk_comp_2323!hvig")); | _click(_image("zk_comp_2323!hvig")); | save |
_click(_span("Order Line")); | _click(_span("Order Line")); | select "Order Line" tab |
_click(_image("zk_comp_3620!hvig")); | _click(_image("zk_comp_3620!hvig")); | select Product,product image |
_click(_image("zk_comp_4498!hvig")); | _click(_image("zk_comp_4498!hvig")); | Refresh button |
_click(_checkbox("zk_comp_4511!cm")); | _click(_checkbox("zk_comp_4511!cm")); | select product "Mary" |
_click(_image("zk_comp_4505!hvig")); | _click(_image("zk_comp_4505!hvig")); | Ok button |
_click(_image("spacer.gif[51]")); | _click(_image("spacer.gif[51]")); | |
_click(_cell("Standard[3]")); | _click(_cell("Standard[3]")); | |
_click(_image("zk_comp_2323!hvig")); | _click(_image("zk_comp_2323!hvig")); | Save image on the toolbar |
_click(_span("Order")); | _click(_span("Order")); | back to "Order" tab |
_click(_cell("Complete[1]")); | _click(_cell("Complete[1]")); | complete order |
_click(_image("zk_comp_5167!hvig")); | _click(_image("zk_comp_5167!hvig")); | Ok button to confirm complete the order |
Above,we found that getting the same records in the two times.That's well !!! :D
Please make sure you just open one adempiere-webui in your browser when record the scripts.
run the scripts by sahi controller
_include("login.sah"); _click(_link("Sales Order")); _click(_image("zk_comp_2319!hvig")); _click(_image("spacer.gif[2]")); _click(_cell("HQ")); _click(_image("spacer.gif[3]")); _click(_cell("POS Order")); _click(_image("zk_comp_2432!hvig")); _click(_image("zk_comp_3132!hvig")); _click(_radio("zk_comp_3160!cm")); _click(_image("zk_comp_3138!hvig")); _click(_image("spacer.gif[14]")); _click(_cell("HQ Warehouse")); _click(_image("spacer.gif[26]")); _click(_cell("GardenAdmin")); _click(_image("zk_comp_2323!hvig")); _click(_span("Order Line")); _click(_image("zk_comp_3620!hvig")); _click(_image("zk_comp_4498!hvig")); _click(_checkbox("zk_comp_4511!cm")); _click(_image("zk_comp_4505!hvig")); _click(_image("spacer.gif[51]")); _click(_cell("Standard[3]")); _click(_image("zk_comp_2323!hvig")); _click(_submit("Order")); _click(_cell("Complete[1]")); _click(_image("zk_comp_5167!hvig"));
Works well,but my play is very slow.(login scripts run well,order creation scripts run very slowly)
test result
Log
review log,found that the scrips start time:at May 28, 2010 2:03:53 PM and last script run at at May 28, 2010 2:55:51 PM
check sahi.properties:
#Time (in milliseconds) delay between steps script.time_between_steps=100 #Time (in milliseconds) delay between retries once an error occurs script.time_between_steps_on_error=2000 #Number of retries once an error occurs script.max_reattempts_on_error=5 #Number of cycles Sahi will wait for the page to load before it proceeds with execution #Time spent is (script.max_cycles_for_page_load x script.time_between_steps) milliseconds script.max_cycles_for_page_load=1200 #No of times Sahi should wait for stability of AJAX and page loads before continuing. min value is 1 script.stability_index=5
No problem!Don't konw why
Base on above scripts you can add assertions.
please refer to :
eg.login script with assertions
_assertExists(_textbox("zk_comp_6")); _setValue(_textbox("zk_comp_6"), "SuperUser"); _assertEqual("SuperUser",_getText(_textbox("zk_comp_6"))); _assertExists(_password("zk_comp_20")); _setValue(_password("zk_comp_20"), "System"); _assertEqual("System",_getText(_password("zk_comp_20"))); _assertExists(_image("zk_comp_73!hvig")); _click(_image("zk_comp_73!hvig")); _assertExists(_image("spacer.gif")); _click(_image("spacer.gif")); _assertExists(_cell("GardenWorld Admin")); _click(_cell("GardenWorld Admin")); _assertExists(_image("zk_comp_137!hvig")); _click(_image("zk_comp_137!hvig"))
Result
test by command
you can test it by command
java TestRunner <suite_name> <browser_executable> <start_url> <log_dir> <sahi_host> <sahi_port> <number_of_threads> <browser_process_name> [<browser_option>]
eg:
sahi # java -cp lib/ant-sahi.jar net.sf.sahi.test.TestRunner /mnt/sda4/Sahi/sahi/userdata/scripts/adempieretest/my.suite "/usr/bin/chromium" http://adempiere/webui default localhost 9999 1 chromium suiteName = /mnt/sda4/Sahi/sahi/userdata/scripts/adempieretest/my.suite browser = /usr/bin/chromium base = http://adempiere/webui sahiHost = localhost port = 9999 threads = 1 browserOption = browserProcessName = chromium Added shutdown hook. http://localhost:9999/_s_/dyn/Suite_start?suite=%2Fmnt%2Fsda4%2FSahi%2Fsahi%2Fuserdata%2Fscripts%2Fadempieretest%2Fmy.suite&base=http%3A%2F%2Fadempiere%2Fwebui&browser=%2Fusr%2Fbin%2Fchromium&threads=1&browserProcessName=chromium&sahisid=sahi_f9684b200038804608097fa0895e8f329e45&html=&browserOption= Status:SUCCESS Shutting down ...
Problems
- my play is very slow
- IDGenerator,just implemented it as a start and test for fields(by CarlosRuiz)
eg.
and cell "English" etc..
so I recorded script like "_click(_image("spacer.gif"));" not "_click(_image("zk..."));"
Other explanation
Now we use ID to confirm the position of elements.
1.sahi controller automatically record elements' position using IDS(zk_comp_*) when adempiere with IDgenerator integration.
2.if ignore ids "zk_comp_*"(Narayan's suggestion),will make the script much more easy to read.the records are the same as adempiere without IDgenerator integration.if use ids "zk_comp_*",the script is not easy to read.
3.above scripts,I recorded them by sahi controller.(assertions you can add them by manually operation or by sahi controller)
4.if want to make the script easy to read,I think need to modify the scripts.
Example:
"_click(_image("zk_comp_137!hvig"))" is same as "_click(_image("Ok24.png");" make it easy to read,you can modify it like "_click(_image("Ok24.png",_in(_table("zk_comp_73!box"))))".
but I think thus script must record by manually operation.
"ignore ids" just record(by sahi controller) scripts like "_click(_image("Ok24.png");"
Links
* Go back to PMC:QA