ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip       Ask Questions on ANYTHING, that arise in your Daily Life at     FORUM9.COM
Google
 
Categories  >>  Software  >>  Scripts  >>  VB Script
 
 


 

 
 PHP interview questions  PHP Interview Questions
 ASP interview questions  ASP Interview Questions
 CGI Perl interview questions  CGI Perl Interview Questions
 JavaScript interview questions  JavaScript Interview Questions
 VB Script interview questions  VB Script Interview Questions
 JSP interview questions  JSP Interview Questions
 Shell Script interview questions  Shell Script Interview Questions
 Python interview questions  Python Interview Questions
 Tcl interview questions  Tcl Interview Questions
 Awk interview questions  Awk Interview Questions
 AJAX interview questions  AJAX Interview Questions
 Ruby on Rails interview questions  Ruby on Rails Interview Questions
 Scripts AllOther interview questions  Scripts AllOther Interview Questions
Question
can any body give the code to write the function for given
suppose user login with usrer id and pwd to yahoomail.after 
cliking "sign in"if it is valid user id the next page will 
display userid'message box.( Note u have to use excel sheet 
to retrive the userid's data)
 Question Submitted By :: Jayanta
I also faced this Question!!     Rank Answer Posted By  
 
  Re: can any body give the code to write the function for given suppose user login with usrer id and pwd to yahoomail.after cliking "sign in"if it is valid user id the next page will display userid'message box.( Note u have to use excel sheet to retrive the userid's data)
Answer
# 1
'Create an excel sheet with username and password
'Get username and password from the excel sheet

Set excelobj=createobject("excel.application")
excelobj.workbooks.open("C:\Documents and 
Settings\12Desktop\test data.xls")
usrname=excelobj.sheets(1).cells(2,1)
pwd=excelobj.sheets(1).cells(2,2)
excelobj.workbooks.close
' add the objects to the Object Repository

'Function for username
Function username
If Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The 
best").WebEdit("login").Exist Then
	If Browser("Yahoo! Mail: The best").Page("Yahoo! 
Mail: The best").WebEdit("login").GetROProperty("disabled")
=false Then
		Browser("Yahoo! Mail: The best").Page
("Yahoo! Mail: The best").WebEdit("login").Set usrname
		reporter.ReportEvent 
micpass,"WebEdit","UsernameEntered: "&usrname
		End If
		else
		reporter.ReportEvent 
micfail,"WebEdit","Username Not Entered"
    End If
End Function
'Calling the username function
username

'Function for password
Function password
If Browser("Yahoo! Mail: The best").Page("Yahoo! Mail: The 
best").WebEdit("passwd").Exist Then
	If Browser("Yahoo! Mail: The best").Page("Yahoo! 
Mail: The best").WebEdit("passwd").GetROProperty("disabled")
=false then
		Browser("Yahoo! Mail: The best").Page
("Yahoo! Mail: The best").WebEdit("passwd").Set pwd
		  	reporter.ReportEvent 
micpass,"WebEdit","Password Entered: "&pwd
		End If
		else
		reporter.ReportEvent 
micfail,"WebEdit","Password Not Entered"
    End If
End Function
'calling the password function
password

'checking the username is valid or not
username="bhadrudu_p"
getdata=Browser("Yahoo! Mail: The best").Page("(1 unread) 
Yahoo! Mail").WebElement("bhadrudu_p").GetROProperty
("innertext")
Function usrvalid
	If  trim(getdata)=trim(username) Then
	reporter.ReportEvent micpass,"WebElement","Valid 
user"
	else
	reporter.ReportEvent micfail,"WebElement","Welcome 
page not present"
End If
End Function

usrvalid
 
Is This Answer Correct ?    0 Yes 0 No
Badri
 
  Re: can any body give the code to write the function for given suppose user login with usrer id and pwd to yahoomail.after cliking "sign in"if it is valid user id the next page will display userid'message box.( Note u have to use excel sheet to retrive the userid's data)
Answer
# 2
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...!
 
Is This Answer Correct ?    0 Yes 0 No
Bfakruddin
 
 
 
  Re: can any body give the code to write the function for given suppose user login with usrer id and pwd to yahoomail.after cliking "sign in"if it is valid user id the next page will display userid'message box.( Note u have to use excel sheet to retrive the userid's data)
Answer
# 3
'-----------------------------------------------------------
--------Create the Connection String -----------------------
------------------------------------------------------------
---------
Function fgGetConnection( )
			'****
			'Purpose:		Get 
connection to Excel Workbook
			'****
			Dim objConnection
			
			Set objConnection = CreateObject
("ADODB.Connection")
		
	objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0
;Data Source='D:\Test Data\Test_Data.xls' ;Extended 
Properties=Excel 8.0;"
			Set fgGetConnection = objConnection
			
End Function
'-----------------------------------------------------------
--------Close the excel connection -------------------------
------------------------------------------------------------
-------
Function fgCloseConnection ( objConnection )
		'****
		'Purpose:		Close connection to 
Excel Workbook
		'****
				objConnection.Close
	
End Function
'-----------------------------------------------------------
--------Fetch the test data from the excel -----------------
------------------------------------------------------------
---------------

Function fgGetData (objConnection, strColumnName, Sheet, 
intPageNumber, TestSetName)
	'****
	'Purpose:		Queries the Excel Workbook 
for one field in the particular Sheet
	'			- Can also take a string 
with comma separated values to get all the columns and give 
it back as an array.
	'****
	'MsgBox strColumnName
	'MsgBox Sheet
	'MsgBox  intPageNumber
	'MsgBox TestSetName
					Dim objRecordSet, 
strQuery
					Dim strScenarioID
					Set objRecordSet = 
CreateObject("ADODB.recordset")
				
	objRecordSet.CursorType = 3 'set CursorType to be 
able to do a RecordCount
					strQuery 
= "SELECT " & strColumnName & "  FROM ["&Sheet& "$] WHERE 
Test_Set = '" & TestSetName & "' AND Step_Number =" & 
intPageNumber & "  AND TestStatus='Y'"
					objRecordSet.open 
strQuery, objConnection
					Select Case 
objRecordSet.RecordCount 
							
	Case 0
							
		fgGetData = ""
							
	Case Else
							
				If InStr(objRecordSet(0), 
Chr(10)) > 0 Then
							
					fgGetData = Replace
( objRecordSet(0), Chr(10), vbNewLine )
							
				Else
							
					fgGetData = 
objRecordSet(0)
							
		'			msgbox fgGetData
							
				End If			
	
					End Select
					objRecordSet.Close
End Function



'***********************************************DB 
Connection Start 
Function****************************************************
****************************

Public Function CreateruntimeObject(Sheetname,ObName)
				'   msgbox ObName
					set 
conn=createobject("ADODB.CONNECTION")
					set 
recset=createobject("ADODB.RECORDSET")
				
	conn.provider="MICROSOFT.JET.OLEDB.4.0"
					
	conn.open "data source='D:\Object 
Repository\Object.xls'; Extended properties=EXCEL 8.0"
						qry="Select 
Properties from [" & Sheetname& "$] where ObjName='" 
&ObName& "'"
					recset.open qry, 
conn, 1, 1
				
				  props= recset.Fields(0)
				  
				
				'Create object description 
for the data fetched from the excel sheet.
				Set obj=description.create()
				arrprops=split(props, "|")
					For i=0 to UBOUND
(arrprops)
					
	arrprop=split(arrprops(i), "=")
					
	propname=arrprop(0)
					
	propvalue=arrprop(1)
						obj
(propname).value=propvalue
				Next
				
				Set CreateruntimeObject=obj
				
				'if object not present????

End Function

'-----------------------------------------------------------
-------- Functional Result update in the testData Excel-----
------------------------------------------------------------
----------------------------
Public Function Resultupdate(objConnection, 
Sheet,TestSetName, intPageNumber, Result, Status)

		objConnection.Execute "update ["&Sheet&"$] 
set TestResult ='" & Result & "', TestStatus ='" & Status 
& "',  Execution_Date =Now  where Test_Set = '" & 
TestSetName & "' and Step_Number =" & intPageNumber  & ""

End Function

'-----------------------------------------------------------
--------GUI   Result update in the testData Excel-----------
------------------------------------------------------------
----------------------

Public Function ResultupdateGUI(objConnection, 
Sheet,TestSetName, Result, Status,objVal,objroPty)
   
			objConnection.Execute "update 
["&Sheet&"$] set TestResult ='" & Result & "', TestStatus 
='" & Status & "',  Execution_Date =Now  where Test_Set 
= '" & TestSetName & "' AND TestStatus='Y'  AND 
Objval='"&objVal&"'  AND Objroproperty='"&objroPty &"' "
			
End Function

'-----------------------------------------------------------
--------Function for Close Application  --------------------
------------------------------------------------------------
-------------
Function CloseApplication(Application)
				dim strcompname, 
strprocesstokill, objwmiservice, compname
				dim colprocess
				Set WshNetwork =CreateObject
("WScript.Network")
			
	compname=WshNetwork.computername 'Get the computer 
name
				
				Set objwmiservice=Getobject
("Winmgmts:\\" &compname & "\root\cimv2") 'Get the task 
manager
				set 
colprocess=objwmiservice.execquery("Select  *  from 
win32_process where name='"&Application&"'") 
					'	Get all the 
processes in an arrary and terminate the required process 
from the task manager.
				For each process in 
colprocess
					  msg=process.name
					 
reporter.ReportEvent micDone, msg, msg & " this has been 
terminated"
					 process.terminate()
				Next
End Function

'-----------------------------------------------------------
--------Invoke outlook Folder Function ---------------------
------------------------------------------------------------
-----------

Function InvokeOutlookFedex()
   
				Const olFolderInbox = 6
				
				Set objOutlook = 
CreateObject("Outlook.Application")
				'
				'If Dialog
("regexpwndclass:=#32770", "regexpwndtitle:=Personal 
Folders Password").Exist(1) Then
				'	pass=Input("Enter 
your Password")
				'	Dialog
("regexpwndclass:=#32770", "regexpwndtitle:=Personal 
Folders Password").WinEdit("attached text:=Type the 
password for.*").Set pass
				'End If
				Set objNamespace = 
objOutlook.GetNamespace("MAPI")
				
				Set objInbox = 
objNamespace.GetDefaultFolder(olFolderInbox)
				
				'msgbox objInbox
				
				strFolderName = 
objInbox.Parent
				
				'msgbox strFolderName
				
				Set objMailbox = 
objNamespace.Folders(strFolderName)
				
				Set objFolder = 
objMailbox.Folders("FedEx QuickShip")
				
				'msgbox objFolder
				wait(5)
				objFolder.display
				wait(3)
				Window(MainPage).maximize
End Function


Public Function Alternateobject(Sheetname,ObName)
'   msgbox ObName
	set conn=createobject("ADODB.CONNECTION")
	set recset=createobject("ADODB.RECORDSET")
    conn.provider="MICROSOFT.JET.OLEDB.4.0"
   'conn.open "Provider=MS.Remote;" & "Remote 
Server=\\Wm6103rbw-1331;" & "Remote Provider = 
MICROSOFT.JET.OLEDB.4.0;" & "data source='\\Wm6103rbw-1331
\Object Repository\Object.xls'; Extended properties=EXCEL 
8.0"
    conn.open "data source='D:\Object 
Repository\Object.xls'; Extended properties=EXCEL 8.0"
	qry="Select Alternate_Prop from [" & Sheetname& "$] 
where ObjName='" &ObName& "'"
	 recset.open qry, conn, 1, 1

  props= recset.Fields(0)

   
''Gets the value into an array
'	Do Until recset.eof
'		For each val in recset.fields
'			props=val.value
'			msgbox props
'		Next
'		recset.movenext
'	Loop

'Create object description for the data fetched from the 
excel sheet.
Set obj=description.create()
arrprops=split(props, "|")
	For i=0 to UBOUND(arrprops)
' 	 msgbox arrprops(i)
		arrprop=split(arrprops(i), "=")
		propname=arrprop(0)
		propvalue=arrprop(1)
'		msgbox propname
'		msgbox propvalue
		obj(propname).value=propvalue
	
Next

Set Alternateobject=obj

'if object not present????

End Function
 
Is This Answer Correct ?    0 Yes 0 No
Hari
 

 
 
 
Other VB Script Interview Questions
 
  Question Asked @ Answers
 
what is the purpose of the Reporter.ReportEvent in QTP and also please give the brief description about Reporter.ReportEvent ? CybAge1
What is a class in CSS?  1
what is the use of Data base check point ?  3
plz give ans to this in vb script........ "krishna radha" i want to print this string "Radha Krishna" like this  3
how to get date format from system locale..format means neither long nor shor... format from system locale. i need like your date is mm/dd/yyyy formate or mm-dd-yy or with time like that. how to get.  2
in qtp we ve datatable look like excel ,if we want to extract data from excel which saved in my documet how can i get that in datatable using vb script  1
how to write function to validate the number of characters entering into the text box? TCS2
Is it possible to pass optional argument to function in vb script?  2
How can I write HTML text to the window in VB Script?  2
Plz give the vb script for the following scenerio. In travel booking we have to select from delhi to mumbai from the combobox The prices will be display in another combo box .But i have to select the lowest price for it and submit it IBM1
we executed QTP scripts in one browser(i.e IN)same scripts is working on another browsers or not (i.e mean netscap,m azol..like ) Accenture6
When inserting strings into a SQL table in ASP what is the risk and how can you prevent it?  1
how to write code: to check whether the window of an Application Under Test exist or not . plz give with example  2
Hi, I need to accept user inputs for login at runtime.I know i can use Inputbox but how to proceed further that i dont know. Thanks in advance  2
WHAT IS ENVIRONMENT VARIABLES?and where it is used in real time scenario?  1
How to create MSAcess table foriegn key  1
what is the function to get the ascii value of the character? Netxcell4
What is wrong with the following code: <%afname="header.asp"%><!?#include file ="<%=afname%>"?>  1
what is descriptive programming in QTP and what is environment variable in QTP? where we store and what is its use? Perot-Systems4
What are the differences between Visual Basic, VBA and VBScript? When would it be appropriate to use one as opposed to another?  1
 
For more VB Script Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com