Tuesday, June 25, 2013
Create log file in QTP
Function LogintoFile(strCode, strMessage)
Dim objFS
Dim objFile
Dim objFolder
Dim strFileName
Set objFS = CreateObject("Scripting.FileSystemObject")
If Not objFS.FolderExists(objFS.GetAbsolutePathName(".") & "\log") Then
Set objFolder = objFS.CreateFolder(objFS.GetAbsolutePathName(".") & "\log")
End If
strFileName = objFS.GetAbsolutePathName(".") & "\log\" & year(date) & month(date) & day(date) & ".log"
Set objFile = objFS.OpenTextFile(strFileName, 8, True)
On Error Resume Next
objFile.Write Date & ", " & Time & ", " & strCode & ", " & strMessage & vbcrlf
' disable the on error statement
On Error GoTo 0
objFile.Close
Set objFS = Nothing
End Function
'Function Calling :
call LogintoFile("Fail","Invalid User Credentials")
Monday, June 17, 2013
Handling web table in Web driver
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class Kesineni {
WebDriver driver;
public void test() throws InterruptedException {
//launch the firefox browser
driver=new FirefoxDriver();
//enter URL Kesinenitravels application
driver.get("http://www.kesinenitravels.com");
//Select source
new Select(driver.findElement(By.id("ctl00_cpEndUserMain_ucSearchRoute_ddlSource"))).selectByVisibleText("CHENNAI");
Thread.sleep(4000);
//Select Destination
new Select(driver.findElement(By.id("ctl00_cpEndUserMain_ucSearchRoute_ddlDestination"))).selectByVisibleText("HYDERABAD");
Thread.sleep(4000);
//Click on Search button
driver.findElement(By.id("ctl00_cpEndUserMain_ucSearchRoute_ibtnSearch")).click();
Thread.sleep(7000);
//Get the text of ServiceNo's
List ele=driver.findElements(By.xpath("//table[@id='ctl00_cpEndUserMain_ucOnwardJourney_gvServices']/tbody/tr/td[2]"));
System.out.println(ele.size());
//print text
//Create one list
List one = new ArrayList();
for(int i=0;i ele1=driver.findElements(By.xpath("//table[@id='ctl00_cpEndUserMain_grdvCheckFare']/tbody/tr/td[2]"));
List two = new ArrayList();
for(int i=0;i
Selenium server start up problems: Failed to start: SocketListener0@0.0.0.0:4444
If the below appear while running the selenium scripts,
Failed to start: SocketListener0@0.0.0.0:4444
you need to kill the process "javaw.exe" by going to the task manager
If this is a routine case then you can write a reusable function and call it wherever required
Monday, June 10, 2013
Capture ToolTip from QTP
'for Web Elements
msgbox browser("browser").Page("pagename").WebElement("webelementname").Object.title
'for images
msgbox Browser("browser").Page("pagename").Image("imagename").GetROProperty("alt")
'for Links
x=Browser("browser").Page("page").Link("linkname").GetROProperty("OuterHtml")
temp=split(x,chr("34"))
ToolTip=temp(1)
msgbox ToolTip
Friday, June 7, 2013
Delete cookies using QTP
SystemUtil.Run "Control.exe","inetcpl.cpl"
Set objShell = CreateObject("Wscript.Shell")
Do Until delcookie = True
delcookie = objShell.AppActivate("Internet Properties")
Wait(1)
Loop
objShell.Sendkeys "%i"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(1)
objShell.Sendkeys "%f"
Wait(1)
objShell.Sendkeys "%d"
Wait(1)
objShell.Sendkeys "{ENTER}"
Wait(4)
objShell.Sendkeys "{ENTER}"
Thursday, June 6, 2013
Prevent system from locking while running QTP scripts
Use the below lines of code in a function that is called frequently
Example: If you have a function to report or function to start your test case etc
set WshShell=CreateObject("WScript.Shell")
WshShell.SendKeys ("^{HOME}")
Example: If you have a function to report or function to start your test case etc
set WshShell=CreateObject("WScript.Shell")
WshShell.SendKeys ("^{HOME}")
Lock PC after suite execution
Set obj = CreateObject("WScript.Shell")
sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
obj.Run sCmnd, 0, False
sCmnd = "%windir%\SYSTEM32\rundll32.exe user32.dll,LockWorkStation"
obj.Run sCmnd, 0, False
Subscribe to:
Comments (Atom)
AI in Software Testing: How Artificial Intelligence Is Transforming QA
For years, software testing has lived under pressure: more features, faster releases, fewer bugs, smaller teams. Traditional QA has done her...
-
Agile software development is a highly iterative and collaborative approach to software development that emphasizes flexibility and a...
-
Test-Driven Development (TDD) is a software development approach that emphasizes writing automated tests before writing the code. The appr...
-
Software development is a complex process that requires a high degree of accuracy, efficiency, and speed. One way to achieve these goals i...