Script threw an uncaught JavaScript error:
Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().popover().actionSheet().buttons()["Save Note"]
Code:
var target = UIATarget.localTarget();
var app = target.frontMostApp();
var window = app.mainWindow();
target.logElementTree();
UIALogger.logPass("Stick Note Save Start");
app.navigationBar().toolbar().buttons()["Plus"].tap();
app.keyboard().typeString("Ki");
window.popover().actionSheet().buttons()["Save Note"].tap();
UIALogger.logPass("StickNoteSaveEnd");
First of all, check correct hierarchy.
Then, try to use
"app.popover().actionSheet().buttons()["Save Note"].tap();"
If it does not work for you, please give some details regarding elements structure/buttons.
I think there is a bug in action sheet access from javascript. You can see my answer to a similar question here.
Bascially I think actionSheet() always returns nil to buttons and elements. It's not supposed to, but everything I've seen suggests otherwise.
MikhailV worked out a function to tap the correct button here.
Related
I often don't exactly know which properties are included in the Parameters of click-events.
In my actual Job I'd like to know which cell was clicked inside an devExpress-Gridview (ASP.NET MVC Extension).
So I fired the Event and logged the Parameters to console:
function OnContext(s, e) {
console.log(s);
console.log(e);
}
With this I got hundrets of properties.
How can I Access e.g. the target-accessKey-Value of the log, attached as screenshot?
The screenshot is from console.log(e); - Parameter:
Object - htmlEvent - target - accessKey
This is only for Example so if someone could explain how to read this Output, I could solve such "Little" Problems better by myself :)
UPDATE
It really seems to be that simple:
const value = e.htmlEvent.target.value;
Didn`t recognize the htmlEvent before :(
if you want just to get a value of the input:
In your case it will be:
const value = e.htmlEvent.target.value;
and in any other case if you use javascript and you have some user events
For example, get value from the input
you should use
const value = event.target.value;
and in your case htmlEvent it is the action of the user
I want to read require files dynamically based on condition say
var clientName= "something";
var file = require('../somepath/ + clientName);
but I want to ask what will it return if the path doesn't exist?
I tried to find using debugger but it goes berserk and ends the debugging!
It will end with Not Found error. This error will be raised also by the require. You can catch this errors globaly. Check this url http://requirejs.org/docs/errors.html#requireargs
You can override the default error handler of requirejs and play around with it to see what is happening
require.onError=function customErr(err){console.log('Custom:'+err)};
require(['../somedummyfile'])
I'm fixing a simple user input mulptiplication table which has been littered with errors.
I'm stuck with a partucular piece of code and do not understand what it means.
When the script is run in firbug it says "TypeError: document.getElementById(...) is null"
This is the code which is attached to html:
var get = function(name){return document.getElementById("name").value;};
var set = function(name,value){document.getElementById("name").value=value;};
That simply means that there is no element with an id property of "name" in the DOM. Perhaps your code runs before the document is ready?
It looks like this code is meant to query the DOM for an element with the id of name:
var get = function(name){return document.getElementById(name).value;};
var set = function(name,value){document.getElementById(name).value=value;};
It means that the element with id = "name" is not found in document. Look in the dom if it exists.
You can also try to add this code as event handler for ready-event to check that it works ok there - as it is already said maybe you run this code before the dom is loaded.
I have a complex function that loops through the elements during the onSuccess: of my js and I'm getting the following error that I haven't seen before.
exception encountered : {"message": "Invalid argument.", "description": "Invalid argument.", "number": -2147024809, "name": "Error"}
The js function looks like this:
if(Object.isArray(list)){
list.each(function(listItem, index){
if(!Object.isUndefined(listItem.disabled)){
listItem.disabled = disableFlag;
}
});
}
that is called from the onSuccess: portion of an Update. My html is a button that is calling the noted function from an onclick. When I run it the onException: always happens and I'm getting the error by:
Object.toJSON(exception)
Has anyone seen this before? I have tried playing around with the functionality and it seems that when I use the button to do what it's supposed to do after a specific sequence of events is the only time this happens. So, I placed an arbitrary link on the page and wanted to see if I clicked that, what would happen and it updated the JSON object on the page and allowed for me to use the button for it's set action without the error. Any help would be appreciated.
Most of the time this kind of error happens in IE when you set an attribute of a DOM element.
If listItem is DOM element then maybe it's not yet added to the document or disableFlag is an invalid value. Or the error happens outside the provided code.
I have been trying to figure out this particular problem in my developer tools, but I've had no luck thus far. I have an error on one of my js files that says
Uncaught TypeError: Cannot read property 'value' of null
The following error refers to the 1st variable of dt_version below. The particular thing is if I comment out the first line of code. I get the same error on the following variables of offload1 and offload2. The variable is a number that I am trying to get passed over. I run this function on my body when the page loads...onload=updatetotal();
function updatetotal() {
var dt_version = document.getElementById("dt_version").value-0;
var offload1 = document.getElementById("capacity_offload1").value-0;
var offload2 = document.getElementById("capacity_offload2").value-0;
var offload3 = document.getElementById("capacity_offload3").value-0;
}
If a run an if statement looking for document.getElementByID("dt_version");...it defaults to false..so its not being carried over though on the previous page, I can see its input fine with the value in it. What am I missing here guys?
This error means that the id dt_version does not exist. Check your html to make sure it is there:
var dt = document.getElementById("dt_version");
if (dt){
// do your stuff
}else {
console.log("dt does not exist")
}
Another cause for this error may be- as you are calling the javascript function on page load there is a possible chance that your control is not yet completely rendered to the page. A simple solution is just move that control to the beginning of the page. If it doesn't work then an reliable solution is, call the function inside jquery $(document).ready().