VB Script Interview Questions and Answers
Use the “title” property to get the tool tip of any button, hyperlink etc.
For this you need create File system object.
Below code is for reading from text file
Const ForRead=1
Dim objFSO, objFile, strText
Set objFSO = CreateObject(“Scripting.FileSystemObject”)
‘Reading code
Set objFile=objFSO.OpenTextFile(“z:filetext.txt”, ForRead)
Do until objFile.AtEndOfStream
strText=objFile.ReadLine
msgbox strText
Loop
objFile.close
Set objFile = nothing
Set objFile1 = nothing
Set objFSO =nothing
“strText” variable will now contain data from text file.
.*12/2/2016.*
Hello Mr.Badri,
Script is good,
if anybody don’t know scripting they will feel difficult to understand your script, please reduce complexity while answering, here no need to use always reporter events you can display with msgbox or with print statements.
How do you think this is correct validation,
–> you get the user name from excel sheet and placed in user name field.
–> you get the text available in user name field again
–> validating these two values.
no test case will be fail if you do testing like this.
you forgot one more thing you have to click Sign In button with out doing this how could you conclude that the user is valid or not….!
Once you get Home page or mail box page then you can conclude that user name is valid
or
If you don’t get any error msg or popup after clicking on Login In then also you can ensure that the user is valid.
If anybody want me to give code, I will give.
above code also correct but some what complexity…!
Even i have stuck with this database check point have you
got the solution for this how to insert a data base check
point pleace could you mail to my id
shiva_uma2003@rediffmail.com thaks in advance
i take cint that i will get mm/dd/yy format
first ofall i capture that value take help stepgenatator later
mm/dd/yyyy change into your format
If window(“Flight Reservation”).Exist<>0 Then
msgbox “window exists”
else
msgbox “window doesnot exists”
End If
In active screen u can see the test objects i.e. the
application at the time of recording. but in movie screen
recorder u can see the screenshots of the application
during runtime.
if Browser(“name:=”abc”).Page(“title:= xyz”).WebEdit
(“name:=username”).Exist(2) Then
Browser(“name:=”abc”).Page(“title:= xyz”).WebEdit
(“name:=username”).Set “Chakri”
End if
function feet(x)
Inch=12
Res= x*Inch
msgbox x&”Feet”& “=”& Res & “Inches”
end function
call feet(2)
Just change instead of 2 any number it ll calu and give u in inches
Hope i answered your question
First save all item names in DataTable with column
name “FlyFrom” and follow the script:
Val1 = dataTable.Value(“FlyFrom”)
i = 0
itm = Window(“F.R.”).WincomboBox(“Fly From:”).GetItem(i)
If Val1 = itm then
reporter.reportevent 0,”
else
reporter.reportevent 1,”
EndIf
i = i+1
Itmscnt =
val =
For itm = 1 to Itmscnt-1
itmval =
(“Price”).GetItem(itm)
If cint(Val) < cint(itmval) then
msgbox "Val is less than itmval"
else
val = itmval
end if
Next
msgbox "Lowest price is: "&val
hello we should change the settings for that
file-> settings->Run->run the row from 1 to 10 then we can
pass the all the parameter from the datatable.
“For” loop can be used when the range of the iteration is
known. For ex: For i = 1 to 100….
“While..do” or “do..While” can be used when, the scenario
should satisfy the condition.
For Ex: While (
Dim StrFunVal
StrFunVal = fn_MyFunction(7)
Function fn_MyFunction(Num)
fn_MyFunction=Num+8
End Function
During the execution the “StrFunVal” variable will contain
the value 15. If you don’t want to use ‘Msgbox’ or ‘Print’
then declaring a variable is prefered.
For your other question I haven’t come across returning
more than 1 value from functions. Probably we have to use a
ARRAY kind of stuff…but not sure. Need to work on it.
Cheers,
VGR
We can use capturebitmap for this two inputs are there one is filetype means need to give path and type of image like png or bmp (“Ex:Login.png”) and rest is true or false. true means if image is there with same name it will overwrite if not it creates the name which we have given..By default true is there.
Browser().page().capturebitmap(“G:Login.png”,true)
for VBScript in QTP orientation visit:
http://www.gcreddy.com
there you can get:
VBScript examples,
GUI Scripts,
Web Scripts,
Database scripts,
Excel scripts,
Flat files scripts etc..
It is a very useful site for QTP advanced learners.
Dim