Get all current forms via code - ranorex

I can identify (find) an element with a certain RanoreXPath via Ranorex Spy, but not via Ranorex API.
Is there a method to output all current \forms on the computer to be able to debug the problem?

var FormElementList = Host.Local.Find("/form");
foreach (var formElement in FormElementList) {
Report.Info(formElement.GetPath(PathBuildMode.Default, Ranorex.Host.Local).ToString());
}

By identify, do you really mean find?
When I encouter problems with troubleshooting an issue, I usually insert Report.Screenshot and Report.Snapshot at strategic places in recordings (or user code).
When Report.Screenshot has no element specified, it captures a screenshot of the entire desktop which can be useful (when tests are executed unattended).
Report.Snapshot does however need an element (/form could be used as suggested by RanorexPro), but if your XPath is incorrect, this won't help much...
Hoping this gives you ideas...

Related

white listing solution against fortify erros does not remove the fortify errors

when i ran fority scanner it reported often misused authentication issue on the below line
hostName=java.net.InetAddress.getLocalHost().getHostName();
I had written a function which will validate this host name against the white list of host names as below.
private String validateHost(String hostName)
{
String[] PossibleHosts = {"host1","host2","host2","host4","host5",};
Integer myhostIndex = Arrays.asList(PossibleHosts).indexOf((hostName).toLowerCase());
if(myhostIndex>=0){
hostName = PossibleHosts[myhostIndex];
} else {
hostName = "";
}
return hostName;
}
which will be called by below line
hostName=validateHost(java.net.InetAddress.getLocalHost().getHostName());
But when i run the fority scan for the next time , it still shows issue on the same line even after i have done the validaiton. what can be done to remove the fortify error.
To answer you, let me explain how Fortify detects this issue, why it's included, then what to do about it.
How Fortify detects this issue: It's basically a super grep. It just finds anywhere you're using java.net.InetAddress.getLocalHost().getHostName() and complains. It is unaffected by data validation.
Why do this? Because this function is sometimes used for security purposes, and it should not be. For example, imagine a dev wanted to trust all messages from their own domain, they might use this to determine where a message came from. But then the security of their system relies on DNS, which is not secure. (See the Details tab for more info.)
What to do: First, make sure that what you're trying to do with java.net.InetAddress.getLocalHost().getHostName() is safe. Basically, that you're not trying to secure your system with this code. Then ignore the finding. At most companies I help, you would write a short explanation of why this code is OK, put it in the comment field of the Issue Summary tab, and mark the Analysis as "Not an Issue." At some places, you could also suppress it. If you're getting a ton of these, you can create a Filter that will knock out the whole category, but realize that you might also knock out some real issues that way.
Source of information: Consultant at Fortify Software 2008-2010, independent application security consultant since then.

Umbraco7 - ContentService.SaveAndPublishWithStatus VS ContentService.SendToPublication

I have an application that uses a combination of ContentService.Saved & ContentService.Saving to extend Umbraco to manage content.
I have two websites in one Umbraco installation I am using those methods to keep content up to date in different parts of the tree.
So far I have got everything working the way I wanted to.
Now I want to add a feature that: depending on which Umbraco User is logged in, will either publish the content or simply send it for approval.
So I have changed some lines of code from:
cs.SaveAndPublishWithStatus(savedNode, 0, false)
To this:
cs.SendToPublication(savedNode);
Now the problem that I am finding is that unlike the SaveAndPublishWithStatus() method, the cs.SendToPublication(); doesn't have the option of passing false so that a save event is not raised. So I get into an infinite loop.
When I attach the debugger and manually stop the infinite loop the first time it calls cs.SendToPublication(savedNode); I get exactly the behavior I want.
Any ideas about how I can get round this problem? Is there a different method that I should be using?
You are correct in saying that it currently isn't possible to set raiseEvents to false when sending an item to publication - that's a problem.
I've added that overload in v. 7.6 (http://issues.umbraco.org/issue/U4-9490).
However considering that you need this now, an interim solution could be that you make sure your code is only run once when triggered by the .Saved / .Saving events.
One way to do this would be to check the last saved date (UpdateDate) in your code. If the content was saved within the last second of the current save operation, you know that this is a save event triggered by the save happening in SendToPublication action. Then you also know that the item has already been sent to publication and that this doesn't need to be done again - thereby preventing the endless loop from happening.

Ranorex Spy - The recognition elements on the page (prioritizing attributes)

I have question related to the Ranorex Spy.
Is it possible to recognize (by default) elements of the page by attribute other than id, e.g. data-id
I know that I can modify this later manually for each element (but it is time consuming)
Currently:
\input[#id='..."]
Expected (automatically, by Ranorex Spy):
\input[#data-id='..."]
I personnally did not bother using this (because we use many frameworks and whats desired in one framework is not necessarily whats desired in another one) but I think you can achieve priorisation of XPath rules using the RanoreXPath Weight Rules.
Following is a Ranorex article describing how to do this: http://www.ranorex.com/support/user-guide-20/ranorexpath-weight-rule-library.html
Good luck!

Trying to fix an auto farming script for a mobile game

I found a 5 month old lua script to automatically farm currency and items in a mobile game called Soda Dungeon, the script was finicky when I found it and wouldn't work properly so I'm trying to fix it with very little lua experience.
Here is the code Ive edited: http://pastebin.com/U9Ymej0z
it runs fine until it tries to start the dungeon and I get this error:
Runtime error: com.appautomatic.ankulua.f:
Can't find dungeon_level_up.png
stack traceback:
[C]: in function 'continueClick'
?: in function <?:291>
(tail call):?
/storage/extSdCard/soda_dungeon/main.lua:
217: in function 'main'
/storage/extSdCard/soda_dungeon/main.lua:
239: in main chunk
Any help is greatly appreciated.
I don't know anything about Ankulua but a quick session with our best buddy google gave me this:
http://ankulua.boards.net/thread/13/advanced-methods
http://ankulua.boards.net/thread/6/objects-methods-introduction-sikuli-compatible
They give those functions:
continueClick(x, y, xRandom, yRandom, times)
continueClick(PSMRL, times [,timeout])
They say continueClick will click on a position given by x,y or PSMRL, which will resolve in a postion as well.
You enter a string that contains an image name.
I assume the message
Can't find dungeon_level_up.png
Is rather an exception text of some find(PS) function inside Ankulua than a problem with finding an image file. Replace that image name with some coordinates and check what is happening.
I would not trust that function call in your script as the author of that script added a comment that he does not know what continueClick returns. So maybe he did not know how to use it as well.
The documentation says:
There is no return value.
Btw, the author of Ankulua offered support via mail. So why don't you ask him? I'm sure he'll be of better help than anyone here.
let me offer you another alternative method, just a few simple click you and drag
It doesn't require root,
background service Installation can be found at the following
hXXp://123autoit.blogspot.tw/2016/08/123autoit-non-root-daemon-service.html
currently only works on ARM
for Android 5.0+
hXXp://play.google.com/store/apps/details?id=com.autoit.nonroot&hl=en
for Android 4.2~4.4
hXXps://play.google.com/store/apps/details?id=com.autoit.nonroot.legacy&hl=en
feel free to send me message to ask for question
here is what it can do
check out the blog, it contains tutorials, and video demo
http://123autoit.blogspot.tw/
Hope everything works out for you,
cheers

Set the Visitor ID in Adobe Analytics through DTM

I'm trying to set the Visitor ID in Adobe Analytics through DTM.
Above the s_code I have:
var visitor = new Visitor("xxxx")
visitor.trackingServer = "xxx.xx.xx.omtrdc.net"
I've created a data element where the legacy code used to call the
Visitor.getInstance("xxxx");
and set the Visitor ID to %Visitor ID%
That's not working however, and my visitor ID is always just set to %Visitor ID% and obviously not reading any values. I'd really appreciate any input that someone can give me.
Thanks,
Mike
The Visitor ID pops s.visitorID and is in general related to visitor id, but is not the same as s.visitor which is what gets popped for the VisitorAPI integration. DTM does not currently have a built-in field for the s.visitor variable, so you will have to set it yourself within the config, either in the Library Management code editor (assuming you are opting to c/p the core lib and not the "Managed by Adobe" option) or else in the Custom Page Code section.
Since you are popping it in a data layer first, you can reference the data layer like this:
s.visitor = _satellite.getVar('Visitor ID');
NOTE: A separate potential issue you may have is with whether or not the Visitor object is available for your data element. Since data elements are the first thing to be evaluated by DTM, you will need to ensure that the VisitorAPI.js library is output before your top page DTM script include.
If this is a problem for you, or if you are wanting to host VisitorAPI.js within DTM, then you may need to adjust where you are popping that stuff. For example, place the VisitorAPI core code above the custom code as the first stuff within the data element, before:
var visitor = new Visitor("xxxx") visitor.trackingServer = "xxx.xx.xx.omtrdc.net
Or, don't use the data element at all. Instead, put the VisitorAPI code within the Adobe Analytics custom code or core lib section and pop all that stuff (aboove the s.visitor assignment). Or a number of other methods; point is, VisitorAPI stuff must be loaded before the data element can make use of it, same as it must be loaded before Adobe Analytics can make use of it.
So DTM is changing pretty fast and furious right now. They have a "Marketing Cloud Service ID" that works well. Before I used that, however, I did find a way to fix the code. Crayon Violent was right, as usual, that the problem was that the script wasn't available yet. I fixed this by putting the following code in between the VisitorAPI.js and the AppMeasurement stuff in the DTM managed library.
var aA = new AppMeasurement();
aA.visitorNamespace="companyname";
aA.visitor = Visitor.getInstance("companyname");
In addition, there were also some issues using my localhost for testing while trying to see if I had this correct or not. If you are having issues and think you have it correct, it may be worthwhile to elevate it to a different environment.

Resources