Ask a Question

Script-How to call a stored value at the project variable in a list

saranoor
Frequent Contributor

Script-How to call a stored value at the project variable in a list

Script-How to call a stored value at the project variable in a list

I am writing a small script.

I am creating a report which generates areport number.

I am storing the value (report number) in a global variable declared at the project level .

I need to identify that report number from a list of reports and click on the report number which is a hyperlink.

 

function foo(){
var itemCount = Aliases.browser.pageUntitledDocument.table;
Sys.Browser("iexplore").Page("http://fred01/index.cfm?fuseaction=MEDFR.OneProject&key=28942 &stid=1&apid=2").Table(1)
var test1 = itemCount.FindChild("text",Project.Variables.MedferReportNumber,5);
test1.DblClick();
}

 

I had succesfully written a script in my earlier test.  

Script running succesfully is as below.

 

function foo(){
//Project.Variables.NewWorkOrderID = 1605152
var itemCount = Aliases.EthelPCWpf.HwndSource_NavigationWindow.NavigationWindow.mWorkOrderList;
var test1 = itemCount.FindChild("text",Project.Variables.NewWorkOrderID,5);
test1.DblClick();

}

 

 

 

 

20 REPLIES 20
saranoor
Frequent Contributor

function foo(){
  var itemCount = Aliases.browser.pageUntitledDocument.table;
  Sys.Browser("iexplore").Page("http://fred01/index.cfm?fuseaction=MEDFR.OneProject&key=28942
      &stid=1&apid=2").Table(1);
  Log.Message(Project.Variables.MedferReportNumber);
 var test1 =  itemCount.FindChild("text",Project.Variables.MedferReportNumber);
 test1.DblClick();
}

I get below error when I run the script.
You are trying to call the "DblClick" method or property of an object
that does not exist.

Okay, did you try what @AlexKaras said about explicitly converting the value?  What happened then?

saranoor
Frequent Contributor

Also, if the 'text' property has a text value, what if you explicitly convert the value of MedferReportNumber variable to be of text type?

 

Where I declared the variable the drop down has a string or integer. There is no Text type to select.

saranoor
Frequent Contributor

After a lot o troubleshooting and adding log messges in script , the variable is not getting stored.

 

The variable mapped name is as below.

Aliases.browser.pageUntitledDocument.table2.textboxMfhreport.contentText

 

Please help

Hi,

 

> There is no Text type to select.

'text' is the name of the property, not its data type. As you are working with web page it must be of string type.

 

> the variable is not getting stored.

How do you store it?

 

> Aliases.browser.pageUntitledDocument.table2.textboxMfhreport.contentText

Does the Aliases.browser.pageUntitledDocument.table2.textboxMfhreport object exist?

 

None of us here is oracle. We have no idea about your tested application likewise how you namemapped your objects. The more relevant info/screenshots you provide the higher the chances that someone can provide you with a piece of advice.

All at all you do not create an issue report for your developers with the 'script application is not working' description, do you?

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
saranoor
Frequent Contributor

> There is no Text type to select.

'text' is the name of the property, not its data type. As you are working with web page it must be of string type.

This is true it is a string type.

 

> the variable is not getting stored.

How do you store it?

I am storing at the Project level 

 

> Aliases.browser.pageUntitledDocument.table2.textboxMfhreport.contentText

Does the Aliases.browser.pageUntitledDocument.table2.textboxMfhreport object exist?

Yes this object exists and this is the set variable object mapping.

 

 

 

Hi,

 

> I am storing at the Project level 

Yes, I can see this from your code. Can you provide the code that assigns a value to the Project.Variables.MedferReportNumber variable?

 

Also, what value do you expect to be stored in this variable?

 

Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
saranoor
Frequent Contributor

The new Medferreport generates a sytem ID and it can be a two digit number, eg 32, 32-A, 32-1.

This is the ID that I am storing in teh global variable.

I am going to another screen where there is a list of reports and I need to open the report that has the report ID stored in Global variable.

Below is ascreenshot of the report list wher I need to open the report from.

MedferREportListMedferREportList

Hi,

 

Can you provide the code that assigns a value to the Project.Variables.MedferReportNumber variable?

OK... It is my understanding that for some reason you prefer not to share your code with us...

Then, just for curiosity, try this code:

function foo()
{
  Project.Variables.MedferReportNumber = "32-A";
 
  Browsers.Item(btIexplorer).Run("http://fred01/index.cfm?fuseaction=MEDFR.OneProject&key=28942
      &stid=1&apid=2"
);
  var Page = Sys.Browser().Page("*fred01*");
  Page.Wait();
 
  var itemCount = Aliases.browser.pageUntitledDocument.table;
  if (!itemCount.Exists)
    Log.Error("itemCount object was not found");
 
//  Sys.Browser("iexplore").Page("http://fred01/index.cfm?fuseaction=MEDFR.OneProject&key=28942
//      &stid=1&apid=2").Table(1);
 
  Log.Message(Project.Variables.MedferReportNumber);
 
  var test1 =  itemCount.FindChild("text", Project.Variables.MedferReportNumber, 50);
  if (!test1.Exists)
    Log.Error("test1 object was not found");
 
  test1.DblClick();
}
 
Regards,
  /Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
saranoor
Frequent Contributor

function foo()
{
var itemCount = Aliases.browser.pageUntitledDocument.table;
//Sys.Browser("iexplore").Page("http://fred01/index.cfm?fuseaction=MEDFR.OneProject&key=28942&stid=1&apid=2").Table(1);
//Log.Message(Project.Variables.MedferReportNumber);
var test1 = itemCount.FindChild("text","Report 41",5);
Log.Message("Report6 "+Project.Variables.MedferReportNumber);
//console.log(test1);
test1.DblClick();
}

 

This is the script that I wrote.

cancel
Showing results for 
Search instead for 
Did you mean: