UFT/QTP: Count child objects in Java Internal Frame - java

I need to compare a string with all values of my text fields that are inside in a Java Internal Frame.
I already tried to use this code:
Dim getElement
Set getElement = Description.Create
getElement("class description").value = "text box"
'I tried different class names: "OracleTextField", "JavaEdit"
'getElement("micclass").value = "OracleTextField"
'getElement("micclass").value = "JavaEdit"
Set obj = Browser("xxxx").JavaApplet("Main").JavaInternalFrame("yyyy").ChildObjects(getElement)
total = obj.Count
' For loop goes here
total returns 0 all the time.
Can you tell me what I'm doing wrong?
If you need something more let me know.

I tried the following line and it works. Now i have total number of text fields available in Java internal frame.
getElement("to_class").value = "JavaEdit"
Following QTP documentation didn't help, but if you check your object properties inside your Object Repository you'll find all properties of each object. Instead of "micclass" try to use your property name. Mine was "to_class" with value "JavaEdit".
QTP Documentation explains why we should use "micclass" and differences between "micclass" and "Class Name". However none of them worked for me. I used "to_class" property and it works fine!
I'm working with UFT v12.02

Related

Step Plugin Development : How to list custom variables inside textVar() input?

I'm trying to develop a step plugin using Pentaho,
I used textVar() Input for listing the variables.
the problem is that the custom variables that created from the previous step aren't listed, so i tried to used environmentSubstitute(${var}) inside my code for fetching the variable's value, and no thing effected !.
so please guide me to the right way for listing the custom variables that created using the previous steps , for listing it inside textVar() input inside my custom step plugin.
After many days of testing , I succeeded of listing previous field names using the follwoing :
Combo wField = new Combo();
String[] inputFields = transMeta.getPrevStepFields(stepname).getFieldNames();
Arrays.sort(inputFields);
for (String fName : inputFields) {
wField.add(fName);
}
That's all :)

Problems with YamlConfiguration.set()

Hey there,
I've got a small problem. I am creating a plugin for Bukkit. I tried to code a in-game config editor - that means that one can change configuration options with a command from inside the game. I already got it to work, but as of the build I'm using (#2879), the method YamlConfiguration.set(String, Object) doesn't seem to work. Here is the essential part of my code for setting and saving the YamlConfiguration I've got.
plugin.debug("option = "+option); // the configuration option
plugin.debug("newvalue = "+value); // the new value
config.set(option, value); // this should set the value of 'option' to 'value'
plugin.debug("savedvalue = "+config.get(option)); // the value saved in the config
As I tested my plugin, I've got the following output.
option = debug
newvalue = false
savedvalue = true
If you need the full and detailed code, look into it on GitHub: GeneralCommands.java, function config(CommandSender, String, String) (line 1074).
Kind regards.
My bad, it was a problem with another method I used (plugin.getConfig()).

Talend and core java

Hi i am using talend here with java. stuck at a situation.
String modCode <br>
for (productsline product: ProdUtil.getProdForProfile(attrs.dhdeProd.profileId))
{
modCode = product.productCode;
System.out.println("products are:" +modCode);
}
this piece of code prints 3 didd modcodes. which is expected. Now i need to use these modcodes in if components.
M unable to do as it says
local variable modcode may not have been initialised in if component.
How can i do it??
Its all about SCOPE.
You need to move the modCode declaration outside of the if block.
Read here the JLS#14 specs on Blocks and Statements
I'm assuming the if block you want to include it in occurs either in or after the for loop. If the warning about initialization is in your IDE, you may want to explicitly set
String modCode = null;
or
String modCode = "";
Your for loop might not execute if the iterator has no entries. This is why you are getting the warning.

How to add parameters to test cases in Test Plan using Java?

I've tried various things and googled multiple hours but couldn't find a solution to my problem.
I'm using the Quality Center OTA API via Com4j to let my programm communicate with QC.
It works pretty good, but now I've stumbed upon this problem:
I want to add new parameters to a test case in "Test Plan" using my programm.
If I used VB it would work somehow like this:
Dim supportParamTest As ISupportTestParameters
Set supportParamTest = TDConnection.TestFactory.Item(5)
Set testParamsFactory = supportParamTest.TestParameterFactory
Set parameter = testParamsFactory.AddItem(Null)
parameter.Name = name
parameter.Description = desc
parameter.Post
Set AddTestParameter = parameter
The important part is the call of AddItem() on the TestParameterFactory. It adds and returns a parameter that you then can give a name and description. In VB the AddItem-method is given Null as argument.
Using Java looks similar at first:
First I establish the connection and get the TestFactory (and the list of test cases).
QcConnect qc = new QcConnect(server, login, password, domain, project);
ITDConnection qcConnection = qc.getConnection();
ITestFactory qcTestFactory = qcConnection.testFactory().queryInterface(ITestFactory.class);
IList qcTestList = qcTestFactory.newList("");
qcTestList contains all tests from Test Plan.
ITest test = qcTestList.item(1);
ISupportTestParameters testParam = test.queryInterface(ISupportTestParameters.class);
ITestParameterFactory paramFac = testParam.testParameterFactory().queryInterface(ITestParameterFactory.class);
No problem so far. All the "casts" are successful.
Now I want to call the addItem-method on the TestParameterFactory, just like in VB.
Com4jObject com = paramFac.addItem(null);
This doesn't work. The addItem()-method always returns null. I've tried various arguments like a random String, a random Integer, the test case's ID, etc. Nothing works.
How do I use this method correctly in Java?
Or in general: How do I add parameters to existing test cases in Test Plan using Java?
Quick note: Adding test cases to Test Plan works very similar to adding parameters to this test cases. You also use a factory and a addItem-method. In VB you give null as parameter, but in Java you use a String (that's interpreted as the name of the test). But as I said, that does not work in here.
I have finally found the answer to this:
Com4jObject obj = iTestParameterFactory.addItem(new Variant(Variant.Type.VT_NULL));
iTestParameter = obj.queryInterface(ITestParameter.class);
iTestParameter.name("AAB");
iTestParameter.defaultValue("BBB");
iTestParameter.description("CCC");
iTestParameter.post();
Regards.
What you want to pass to AddItem is DBNull and not null.
In VB it's the same, but in Java & .NET it's not.
Not sure how DBNull is exposed using Com4J.
Read more about this at this site.
//C# code snippet -> You have to use DBNull.Value instead of null
//Add new parameter and assign values
TestParameter newParam =(TestParameter)tParamFactory.AddItem(DBNull.Value);
newParam.Name = "ParamNew";
newParam.DefaultValue = "DefaultValue";
newParam.Description = "AnyDesc";
newParam.Post();

JRules Studio - Display values of IN_OUT parameters while testing

I'm using JRules Studio to develop some extremely simple rules. The rules populate an IN_OUT parameter. When the test finishes, is there a way of interrogating the values in the IN_OUT object?
Initially I'd like to interrogate it in the debugger, but any other ideas would be welcomed.
I am not sure to understand the question:
Your JAVA code is like this:
IlrSessionFactory factory = new IlrJ2SESessionFactory();
IlrStatelessSession session = factory.createStatelessSession();
IlrSessionRequest sessionRequest = factory.createRequest();
sessionRequest.setRulesetPath(“/RuleAppName/rulesetName”);
sessionRequest.setTraceEnabled(true);
sessionRequest.getTraceFilter().setInfoAllFilters(true);
Map inputParameters = new HashMap ();
Report in_report = new Report(); // no-arg constructor
// ... populate the Object ...
inputParameters.put("report", in_report);
sessionRequest.setInputParameters(inputParameters);
IlrSessionResponse sessionResponse = session.execute(sessionRequest);
Report out_report = (Report)sessionResponse.getOutputParameters().get("report“);
And then you play with your "out" parameters... As you would do with any JAVA object
If you want to see them at debug time, I would say:
1/ (not tested) Have a look on the "working memory tab" in the debugger perspective
I am not sure but this is the easiest way to find them if it is visible here
2/ (tested) in the initial action of the starting point of your ruleflow, add:
context.insert(the technical name of your parameter);
Not the "business name". Anyway avoid using BAL in technical artifact such as ruleflow, IRL rules!
By doing this you force the engine to insert your parameter in the working memory.
No duplication (don't worry, it will work like a charm) but as far as I can remember this is the shortest way to make them visible in the Eclipse debugger in JRules
Hope it helps

Categories

Resources