Monday

Selenium - If Object exist or not

I want to verify for a label if it exists on the webpage or not. As
the website uses pagination if the element is not available on the
first page, it can be found on the next page too. I am using selenium
RC for Java.

for any object use isElementPresent . It return true if object exist
(selenium.isElementPresent("link=yourlinkname")!= false

Xpath also can be use instead of object name

boolean flag=Globals.selenium.isElementPresent("//div[@id='portlet-wrapper-126']/div[2]/div/div/form/div[7]/table/tbody/tr[3]/td[8]/ul/li/strong/span");

if(flag==true)
{
System.out.println(flag);
Globals.selenium.click("//div[@id='portlet-wrapper-126']/div[2]/div/div/form/div[7]/table/tbody/tr[3]/td[8]/ul/li/strong/span");
Globals.selenium.click("//a[contains(@href, \"javascript:_126_deleteOrganization('20727');\")]");
//assertTrue(Globals.selenium.getConfirmation().matches("^Are you sure you want to delete this[\\s\\S]$"));
}
else
{
Globals.selenium.click("//div[@id='portlet-wrapper-126']/div[2]/div/div/form/div[6]/table/tbody/tr[3]/td[8]/ul/li/strong/span");
Globals.selenium.click("link=Delete");

}


verify a label :
use isElementPresent(label Id),

if it's text on page as link then use isTextPresent().
selenium.isTextPresent("link text");

Saturday

QTP- recover Scenario

.qrs file created
QTP recovery senario only invoke in test object...
x=4/y par will not invoke... use on error resume next instead
-----
Trigger and recovery steps
popup -> spy
Object state -> Spy the object state -> function call
Run error -> any error , obj not found , duplicate found -> function call
Application error -> crash etc -> function call

Step: Run current action , iteration , stop, re run cuurent , start window etc



to explicitly invoke recovery
Recovery.Activate
Calling function:
put the action status failed
Function RecoveryFunction1(Object, Method, Arguments, retVal)
sCurrentAction=Enviornment. Value("CurrentAction")
Enviornment. Value(sCurrentAction)="Failed"
Enviornment. Value("RunStatus")="Failed"
End Function
**************************
Recovery Object
Recovery.Activate'Retrieves the name and source file of a recovery scenario, according to the specified position in the list of recovery scenarios associated with the test. Recovery.GetScenarioName
'Returns the position of a recovery scenario in the list of recovery scenarios associated with the test, according to the specified name and source file. Recovery.GetScenarioPosition
'Returns the status of a recovery scenario (True = enabled or False = disabled), according to the specified position in the list of recovery scenarios associated with the test. Recovery.GetScenarioStatus
'Enables or disables the specified recovery scenario, according to its position in the list of recovery scenarios associated with the test. Recovery.SetScenarioStatus
'Enable or disable recovery by Recovery.Enable=False'orRecovery=False
'The following example uses the SetScenarioStatus method to disable the status of the second scenario associated with the test.
msgbox Recovery.Count,, "Number of Recovery Scenarios"
msgbox Recovery, "Is Recovery enabled?"
for Iter = 1 to Recovery.Count
Recovery.GetScenarioName Iter, ScenarioFile, ScenarioName
Position = Recovery.GetScenarioPosition( ScenarioFile, ScenarioName )
msgbox Recovery.GetScenarioStatus( Position ), "Is scenario " & _ ScenarioName & " from " & ScenarioFile & " enabled ?"
ScenarioFile = Empty
ScenarioName = Empty
Next
Recovery.Activate
Recovery.SetScenarioStatus 2, False
Recovery.Activate
*************************

QTP- Debug enable

if Microsoft script debugger is not intalled then Install it otherwsie execution will run in Fast mode !

For command tab : remember just give the varible name ="value " and then enter

and see the variable tab in debug viwer and resume running test in debug mode.

QTP - creating non unique browser with property "openurl "

browserid_openUrl=RandomNumber.Value(10000,99999)dpbrowser="OpenURL:=about:" & browserid_openUrl
msgbox browserid_openUrl
systemUtil.Run "iexplore.exe" , "about:" & browserid_openUrl'systemUtil.Run "iexplore.exe"browser(dpbrowser).Navigate "www.google.com"