Quick summary of QTP
QTP Quick summary:
Automation Frameworks
- Record and Playback.(Records application flow using QTP and playback)
- Data driven. (Data controls the automation flow through a spreadsheet/datatable)
- Keyword driven. (Functions are mapped to Keywords)
- Hybrid approach (Combination of Keyword and data driven)
- Business process testing(BPT)
- Functional Decomposition
Types of QTP Licenses
- Seat
- Concurrent
How to record/playback
- Open QTP/UFT
- Click on File > New Test
- Click on the ‘Record’ button
- Perform actions on the application under test
- Click ‘Stop’ at the end of Recording session
Types of QTP/UFT Add-ins
- Activex Controls
- Web
- Visual Basic
- Java Add-in 8.2
- Terminal Emulator for mainframe
- .NET
- Oracle
- SAP Solutions
- PeopleSoft
- Siebel
- Web Services
- Etc
What is Record and Run Settings
- Record and Run Settings window will be triggered right after the recording started for a new Test or an existing test.
- user can see tabs based on the loaded Add-in
- user can provide Application under test input criteria (like url, application path etc)
What are the various Recording Modes
There are 3 recording modes available
- Standard Recording: this is used for normal recording to capture user operations on the application.
- Analog Recording: this will record the exact mouse and keyboard operations.
- Low level Recording: this will record the mouse movements with respect to the coordinates on the AUT (application under test) Window.
What is Expert View
- Shows the every user actions done on the application in the form of codes.
Active Screen view
- Every code generated after recording will show corresponding application screen on Active screen window. This will help tracking the code vs application objects.
Actions in QTP:
It’s the recorded set of codes which are logically meaningful to the application flow. E.g Customer creation flow.
Types of actions in QTP:
- Non-reusable Action – action that can be called only in the test where it is stored, and can be used only once.
- Reusable Action – action that can be called from any QTP/UFT test
- External Action – reusable action stored with another QTP/UFT test. External actions are read-only.
Object Repository in QTP/UFT:
- QTP stores the recorded object details in a specific location in the tool named the ‘Object Repository’
- Browser – page – Objects are stored in a hierarchal manner.
- Every object will have some listed set of methods as e.g button can perform Click using QTP codes.
How to sort array values in qtp
Dim yourArray
Dim firstIteration
Dim secondIteration
Dim tempValue
yourArray=array(191,101,144,122,117,111,126,199,145,150,177,1,20202)
msgbox lbound(yourArray)
msgbox ubound(yourArray)
For firstIteration=lbound(yourArray) to ubound(yourArray)
For secondIteration=lbound(yourArray) to ubound(yourArray)-1
If oArray(secondIteration)>yourArray(secondIteration+1) Then
tmp=oArray(oCounter2)
yourArray(secondIteration)=yourArray(secondIteration+1)
yourArray(secondIteration+1)=tempValue
End If
Next
Next
For firstIteration=lbound(yourArray) to ubound(yourArray)
print yourArray(firstIteration)
Next
How to find duplicate character in string
Dim objStr
Dim objArray
Dim objchar
objStr = Inputbox(“Enter a String having some duplicate characters in it – as e.g. aacanddoodd”)
objchar= Inputbox(“Input the character you want to find which is duplicated or not as e.g. a or d or o”)
objArray=split(objStr,objchar)
print ubound(objArray)
How to execute javascript in webdriver using javaScriptExecutor using executescript method
How to Execute Javascript in Webdriver using Javascriptexecutor using executescript method?
JavaScriptExecutor can be used to execute javascript in WebDriver. JavaScriptExecutor actions like the way Xpath, Link, CSS, Id locators works in Selenium Webdriver.
javaScriptExecutor is supported by Selenium library and for that you need to import ‘org.openqa.selenium.JavascriptExecutor ‘ in your program.
In Selenium, javaScriptExecutor works like an interface and facilitates Javascript execution in there.
JavaScriptExecutor has two methods.one of the method is as below,
1) executescript – This method will block the execution of next line of code unitl it is completed.
example:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript(Script,Arguments);
Example for executeScript
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class ExecuteScriptExample {
@Test
public void ExecuteScriptTest()
{
WebDriver driver= new FirefoxDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.get(“your website url having login option”);
WebElement button =driver.findElement(By.name(“xxxxxxxx”));
driver.findElement(By.name(“uid”)).sendKeys(“admin”);
driver.findElement(By.name(“password”)).sendKeys(“admin”);
js.executeScript(“arguments[0].click();”, button);
js.executeScript(“alert(‘Test is completed – welcome to home page’);”);
}
}
How to execute javascript in webdriver using javaScriptExecutor executeAsyncScript Method
How to Execute Javascript in Webdriver using Javascriptexecutor using executeAsyncScript method?
JavaScriptExecutor can be used to execute javascript in WebDriver. JavaScriptExecutor actions like the way Xpath, Link, CSS, Id locators works in Selenium Webdriver.
javaScriptExecutor is supported by Selenium library and for that you need to import ‘org.openqa.selenium.JavascriptExecutor ‘ in your program.
In Selenium, javaScriptExecutor works like an interface and facilitates Javascript execution in there.
JavaScriptExecutor has two methods and one of the method is as below,
1) executeAsyncScript – This method will not block the execution of next line of code. Page rendering is fast here.
example:
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeAsyncScript(Script,Arguments);
Example for executeAsyncScript
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class ExecuteAsyncScriptExample {
@Test
public void ExecuteAsyncScriptTest()
{
WebDriver driver= new FirefoxDriver();
JavascriptExecutor js = (JavascriptExecutor)driver;
driver.get(“your website url”);
driver.manage().window().maximize();
driver.manage().timeouts().setScriptTimeout(30, TimeUnit.SECONDS);
long BeginTime = System.currentTimeMillis();
//executeAsyncScript() method is used to enable 10 seconds wait.
js.executeAsyncScript(“window.setTimeout(arguments[arguments.length – 1], 10000);”);
long EndTime = System.currentTimeMillis();
System.out.println(“Passed time: ” + (EndTime – BeginTime));
}
}
How to create a word document using VBscript in QTP?
How to create a word document using VBscript in QTP?
Dim oWordDocument
‘ To initaiate a Word Document object
Set oWordDocument = CreateObject(“Word.Application”)
oWordDocument.Documents.Add
‘ type words on documents
oWordDocument.Selection.TypeText “This is 1st line text on word file ” & vbnewline & “This is 2nd line text on word file”
oWordDocument.ActiveDocument.SaveAs “C:\SampleWordDoc.doc”
oWordDocument.Quit
Set oWordDocument=Nothing
How to find the alpha characters in a given string
How to find the alpha characters in a given string
Dim objStr
Dim objLength
Dim objChar
objStr=”1q2w3etest”
objLength=len(objStr)
alphacount=0
For i=1 to objLength
If not isnumeric (mid(objStr,i,1)) then
alphacount =alphacount+1
alphacharacter = alphacharacter & mid(objStr,i,1)
End if
Next
msgbox “alpha chara count is ” & alphacount
msgbox “alpha charaters are : ” & alphacharacter
How to check the given string is a Palindrome using VB script
How to check the given string is a Palindrome using VB script
MyString = Ucase (Inputbox(“Enter a String :”))
RevString =strreverse(MyString)
if strcomp (MyString, RevString)= 0 then
msgbox “The given string is a Palindrome”
else
msgbox “The given string is NOT a Palindrome, please try another one”
end if
How to run java script on webdriver
Steps,
- create a java project using Eclipse IDE
- add a package and then a class (refer below code for package name and class name)
- then add necessary jar files (selenium-server-standalone-2.53.0, testing, etc)
- then copy/paste and update the code in your IDE
- place chromedriver in the folder and update code below for folder “Users/shali/Downloads/” path matching your pc folder
- run your script to verify results.
JavaScriptExample;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.remote.DesiredCapabilities;
public static void main(String[] args) {
options.addArguments(“window-size=1024,680”);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
((JavascriptExecutor) driver)
.executeScript(“alert(‘testing for java script’);”);
}
}