Monday, May 30, 2011

Selenium Assertions - Assert Vs Verify(Soft Assertions) Vs WaitFor

Selenium Assertions - Assert Vs Verify(Soft Assertions) Vs WaitFor

All Selenium Assertions can be used in 3 modes: "assert", "verify", and "waitFor".

When an "assert" fails, the test is aborted.

When a "verify"(Soft Assertions)  fails, the test will continue execution, logging the failure. This allows a single "assert" to ensure that the application is on the correct page, followed by a bunch of "verify" assertions to test form field values, labels, etc. You don't have this facility in Selenium RC. You can implement the same using TestNG framework, select this link for custom TestNG code implemented using listeners.

"waitFor" commands wait for some condition to become true (which can be useful for testing Ajax applications). They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting (setTimeout).

---

Sunday, May 1, 2011

VB Script - Edit xml document.

VB Script - Edit xml document.

Recently I was performing a load test on Web service that consume XML document. The load test parameters are: upload 2000 XML files sequentially having different ID's (XML document contain  "PayloadID" and "OrderID" that should be unique). In order to create 2000 XML files with unique id's I have created following VB script.
  
Path = "C:\Documents and Settings\bharathm\Desktop\"
xmlfile=Path & "orginal.xml"    'your source file name
NumberOfFiles = 2
AppendString = "B"

set oparser=createobject("msxml2.domdocument")
with oparser
    .async=false
    .validateOnParse=false
    .resolveExternals=false
    .load xmlfile
end with
    
if oparser.parseerror.errorcode<>0 then
    wscript.echo "xml file " & xmlfile & " is not well-formed." & vbcrlf & "Operation aborted."
    wscript.quit 999
end if

for count = 1 to NumberOfFiles
 value = AppendString & count 'Unique string to update document
 set oroot=oparser.documentElement
 oroot.setAttribute "payloadID", value
 Set currNode = oparser.documentelement.selectSingleNode("//cXML/Request/OrderRequest/OrderRequestHeader")
 currNode.setAttribute "orderID",value
 outfile=Path & "TestFiles\" & value &".xml"   'create new output file with unique name
 oparser.save outfile
next
    
set oparser=nothing 
wscript.echo "Completed"

I hope this post will help you in manipulating XML document and make duplicate copies.

---