Item missing from WebList - vbscript

I am writing auto test scripts in QTP (UFT).
I have multiple columns in an external datasheet which could contain data or be blank. I was trying write some code, that if it was blank to click a submit button, if not blank then add in the fields. Please see code below:
If IsNull(DataTable("Available_Qualifications_1", dtLocalSheet)) = False then
Browser("Create Qualification Types").Page("Create Qualification Types").WebList("qavailable").Select DataTable("Available_Qualifications_1", dtLocalSheet)
Browser("Create Qualification Types").Page("Create Qualification Types").Link("Add Qualifications").Click
ElseIf IsNull(DataTable("Available_Qualifications_1", dtLocalSheet)) then
Browser("Create Qualification Types").Page("Create Qualification Types").WebButton("Submit").Click
End if
However, I receive the error below:
Cannot identify the specified item of the qavailable object. Confirm that the specified item is included in the object's item collection.
Line (16): "Browser("Create Qualification Types").Page("Create Qualification Types").WebList("qavailable").Select DataTable("Available_Qualifications_1", dtLocalSheet)".

What UFT is saying is that you're trying to set a value into the WebList which isn't one of the WebList's options.
Try outputing the value to see if UFT is correct, if it is then correct your test (by entering the correct values in the data table). If it's not correct you can try using the index by using the Select "#3" syntax (and report the problem to HP's support).

Related

How can we get the value of textbox in QTP?

I am executing the automated test scripts in UFT 12.5 I am new to UFT. Not very familiar with codes.There is an edit box wherein i have to type the value "S05292". Example:
Browser(Browsername").Page("Pagename").WebEdit("ctl00$ConBody$txtPDNumber").Set "S05292"
The problem is my script fails at this step and does not type the value. Can somebody provide me with a solution which is easy to understand. I tried the below two methods
Method (1)
a=Browser().page().webedit(ctl00$ConBody$txtPDNumber).getroproperty("value")
if a=="S05292" then
msgbox ("displayed message is S05292")
else
msgbox ("msg is not S05292")
end if
Method (2)
x = Browser("Browsername").Page("Pagename").Webedit("ctl00$ConBody$txtPDNumber").GetROProperty("value")
msgbox x
The error message that displays is
Cannot identify the object "ctl00$ConBody$txtPDNumber" (of class WebEdit).
Verify that this object's properties match an object currently displayed in your application.
Use the Object Spy to get the properties of that text box at run time and then make sure they match up to the properties of that text box in your object repository that you defined. Perhaps that don't match up or you didn't uniquely identify that text box.
If you don't want to use an object repository then you have to pass it a property at run time to uniquely identify it. Some thing like:
Browser().page().webedit("developer name:=PDNumber").
Instead of a .set you can do a .type to set/type the value into the text box

object is disabled {:element=>#<Selenium::WebDriver::Element:

We are using a drop-down to select 'Yes' 'No' values from the list. This method is being used across multiple pages. When I run my script it fails saying "Object is disabled" even though it is running fine for first drop down of the page.
Below is the code we are using
def select_value(value, field)
get_screen_element(field).options.map(&:text).include? value }
Watir::Wait.until{get_screen_element(field).select value}
end
Sometimes the script runs fine without errors sometimes it dosen't, its not consistent.

Will this VBSCRIPT code trigger the message box?

I'm looking through at an old Classic ASP page that uses VBScript. The code below appears to use a variable stored in the config (global.asa) called called CODES_TIMESTAMP. However looking at the servers in question it appears that that variable no longer exists. My question is, if that variable is not defined in the config file then will the error message box be activated?
Dim DB_TIMESTAMP_CODES
DB_TIMESTAMP_CODES = "<%=Application("CODES_TIMESTAMP")%>"
If trim(DB_TIMESTAMP_CODES) = "" Then
msgbox "Setup Error... Codes are not Defined"
End If
My question is, if that variable is not defined in the config file then will the error message box be activated?
Value will be "". But msgbox cannot be executed on ASP web page. msgbox will appear only from VBS script.
The code below appears to use a variable stored in the config (global.asa) called called CODES_TIMESTAMP
You (previous developer) could assign value to Application variable from any page. I suggest you to make full search over all .ASP pages, may be this value assigned not in GLOBAL.ASA

Ruby cucumber automation suite - parameter received as null while iterating

I inherited a test automation suite and while modifying it I am trying to write a function to test similar links which are present in the same web page but in different divs and the tag ids are dynamic.
I have a function defined below which accepts an HTML element and sends an action to the element
def element_do(html_element, html_element_type, html_element_value, action)
#browser.send(html_element.to_sym,html_element_type.to_sym ,html_element_value).send(action)
end
I have a method defined as somemethod and I am trying to call the method in a particular div using the some_element#{i} as below
def multiple_accounts
#num_accts.each do |i|
p "validating for account #{i}"
#page.element_do(:div,:id,"some_element#{i}",somemethod)
end
The issue I am facing is that on second iteration the action parameter is passed as null instead of the somemethod. I am new to ruby automation and I am not sure what exactly is happening. Any help is appreciated
Additional details - based on the questions
1) #num_accts is an array which is got by scanning the text of the webpage and contains account numbers (eg: [56544, 87990])
2) This forms a part of the id for the divs as in "acct#56544". So I am passing the array elements from num_accts to "acct#{i}" referred as 'some_element'
3) 'Somemethod' is a method defined to click on a particular link in the div and verifies a text to confirm that the link redirects to the correct page. The some method works fine when there is only one div.
It is not evident from the question, but my suspicion is that you try to pass the name of the method (which returns null), but instead you call the method. I think your call should be:
#page.element_do(:div,:id,"some_element#{i}",'somemethod')

Coded UI test failing in Visual Studio 2013 when entering a blank value from a csv into a WPF data grid

I am running a coded ui test in Visual Studio 2013 into a WPF data grid using values from a csv file. When I have a blank value in the csv file eg ,, it is working fine for input fields but when it comes to entering the empty string into a field on the data grid the coded ui test fails with the following error:
An exception of type 'System.ArgumentNullException' occurred in Microsoft.VisualStudio.TestTools.UITesting.dll but was not handled in user code
Additional information: Value cannot be null.
When I run the test manually I can submit the form without this value so I know it is not mandatory on the UI, the code just seems to be falling over if a value is not sent. If I enter a value on the csv the test will run but I deliberately want the field to be empty.
Has anyone come across this problem before and if so is there a way I could either adapt the csv or the code to get this to work? I have also tried ,"", and this did not work either.
Thanks
I think the way you're doing it (using the isNullOrWhiteSpace method to determine if you should skip entering the value) is the right way. If you don't want to write that each time you're entering values into the field, you could write an extension method instead:
public static void EnterValue(UITestControl control, string inputString)
{
if (!String.IsNullOrWhiteSpace(inputString)
Keyboard.SendKeys(control, inputString);
}
And then just call that when you want to enter text:
string csvValue = /*value from the .csv file*/
StaticUtilityClass.EnterValue(myControl, csvValue);
Not a ground breaking change, but it would cut down on the number of times you have to write that if-statement.

Resources