I'm trying to get MonkeyTalk working with Javascript. I'm automating some tests with iOS. When I run the .MT version, the test runs fine. But, the Javascript version errors with this.
ERROR sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot find function uISearchBarTextField. (RADialerDirectory.js#8) in RADialerDirectory.js at line number 8
The export javascript code shows this:
this.app.uISearchBarTextField().tap();
Anyone know how to get around this error? I'm just trying to use the Javascript version of the script to loop and later grab external data to iterate through.
I had the same problem for "UIAleartView". There are three ways to get it work. this happen because MonkeyTalkAPI.js file doesn't contain an entry for "uISearchBarTextField"
Use more generic type(Input) like above answer.
Set accessibilityLabel property of that component and use it as a monkeyID like here: MonkeyTalk : Verify custom UITableViewCell Label text without select the cell
A little hack to MonkeyTalkAPI.js class. find the word for "Input" which is more generic to your "uISearchBarTextField" and get a copy of it paste it again in that file and edit replaceing "Input" with "uISearchBarTextField" save it and run. if you did it carefully it works.
Happy Testting
Related
I have a simple pdf file containing an embedded file (test.xml) I'm trying to add a JS to call it once the pdf file is opened (even with notification to user to accept the risk etc). I've read that to perform that, the JS that should be used is this:
this.ExportDataObject({cName:"test.xml", nLaunch:2});
For some reason, it is not working. I checked the debug js console on my Acrobat reader DC (version 2021.001.20145) the the error shown is TypeError: this.ExportDataObject is not a function. I'm not sure why on my "this" object the ExportDataObject is not available... I think it should be available always, shouldn't it? I also tested without the this. and the error is different ReferenceError: ExportDataObject is not defined.
That makes to think to me that this.ExportDataObject is existing but is not a function as the original error said... but, if is not a function, what is? a typeof is showing "undefined". Not sure how to make this work. Not sure if next steps should more JS debugging or if the problem is related to something on pdfs or Acrobat. Any help? thanks.
Javascript function names are case-sensitive and as documented by Adobe (p. 151), the correct spelling is exportDataObject() without the leading capitalization.
I believe you misspelled ExportDataObject()
It should be exportDataObject()
Using Javascript you should be careful as it is easy to mess up spelling as JS will interpret that in different ways.
As like most of the languages, js is also case sensitive.
But ReferenceError: ExportDataObject is not defined, ReferenceError always states that the object is not defined at all, and could'nt be found among the class methods.
so you need to make sure the function with the exact exportDataObject name is present and use them accordingly.
I have done a microsoft tutorial called Web API with Javascript
I now have a UI made with Javascript and HTML which looks like this:
How do I use the UI? I keep getting a Reference Error. Is there a specific syntax I am supposed to follow when I add and edit something via APIs?
In the future, please copy and paste error messages into your question. I would normally copy and paste the error message in my answer, but I don't want to type it all out :)
The errors (red) mean that you're trying to use JavaScript that is not defined yet. The warnings (yellow) are the reason why.
The second warning says that it could not load the JavaScript. That explains the errors. The first warning might be the reason why. It's saying that the MIME type is empty, when it should be application/javascript.
But you said in the comments that the site.js file is empty when you try to access it directly. Did you save all the JavaScript in step 4 of that tutorial to site.js?
And what are you using as a web server? IIS Express?
I'm trying to change the score from Patch editor, but when I use the Patches.Get(data)value, always get an error.
[Spark AR editor] (http://prntscr.com/p9b77g)
Still getting this error
JavaScript error: Exception in native code while calling a function: Trying to get signal to Script with name (text). Please make sure to define a ToScript patch with that name in the patch editor
My code script.js opened using Visual studio code.
// Load in the patches module
const Patches = require('Patches');
// Get the 'myText' string from the Patch Editor
const myString = Patches.getStringValue('text');
It should be fine since I've tried the exact name, but I'm still getting that error.
Please make sure to define a ToScript patch with that name in the patch editor
This makes it seem like you don't have a patch called 'text'. For this to work you'll need to select your script in assets, in the 'To Script'-section click the plus icon, select text, rename that from 'EditorToScriptVar(x)' to 'text' and then click the arrow to add it to your patch editor.
I ran into a similar problem once I added more definitions added. Even though the ToScript patch was already defined, the script failed to find it.
To solve this, I delete the producer patch and created a new one. The error should go away and the simulator should resume. Connect your wires and it should continue to work.
I will be following this thread for a few days.
Actually I've two questions, because the common workaround for my initial problem does not work :)
I'm trying to build an Emscripten based library which calls JavaScript functions as described here: https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#implement-a-c-api-in-javascript
Simply put I just implement my C/C++ code against a C-Function, implement that function in a .js file and 'link' that file using --js-library.
Basically things are working for me except with version EMSDK version 1.38.12 I got a warning when linking the final library:
warning: undefined symbol: foo_
.. which I don't understand but I could just ignore it. In newer versions of EMSDK the behavior changed and the warnings become errors.
Searching for this error you find you can just add -s ERROR_ON_UNDEFINED_SYMBOLS=0 when linking, but this doesn't work (for me) - I still get this error despite I can see this option being added to the linker.
So my questions are:
how do I make -s ERROR_ON_UNDEFINED_SYMBOLS=0 work for me?
and why do I get this warning in the first place? how do I get rid of it?
I wrote an HTA that reads information out of a bunch of text files and displays the results to the screen using the following pseudo-logic:
loop through a directory and add the content of each text file to an array
loop through the array's 2 dimensional structure to build a table layout
update itself using a setInterval timer
I originally wrote it in purely vbscript/HTML which worked perfectly but then I needed a way to sort the displayed results by the third column or the array[x][2] value.
So I turned to javascript as it has much more friendly/quicker array usage. I rewrote the functions so that the pseudo-logic looks like:
loop through a directory and add the content of each text file to a JAVASCRIPT array
SORT the JAVASCRIPT array by the array[x][2] idx
Flatten the 2D JS array into a string using separators
Split the sorted JS string into a VBS array and build table layout the exact same way
update self using setInterval timer
after working out the syntax errors, the initial HTA load works perfectly as I'd intended it to. But now, upon the setInterval() update, I get a generic JS error:
Line: 1
Char: 1
Error: Object doesn't support this property or method
Code: 0
URL: file:///pathToHTA.hta
I've gone so far as to comment out the entire update function I'm using with setInterval() so that the function gets called but it doesn't actually do anything and I STILL get the error.
I'm at a loss as to where to go from here and am hoping someone might be able to give me some pointers as to what might be causing this error. Thanks in advance.
So I found the problem:
For whatever reason, I had to switch the order of my script declarations. In the original one with errors I was declaring my scripting in this order:
<script type="text/javascript">
...
</script>
<script type="text/vbscript">
...
</script>
The fix was that (for whatever reason), I had to flip-flop the delcarations.
I changed the order so that my vbscript functions were listed first and javascript ones second and this resolved the error.... anyone know why that would be?