无法对无效元素执行操作:UIAElementNil

Cannot perform action on invalid element: UIAElementNil

本文关键字:操作 UIAElementNil 执行 元素 无效      更新时间:2023-09-26

Script抛出了一个未捕获的JavaScript错误:

Cannot perform action on invalid element: UIAElementNil from target.frontMostApp().mainWindow().popover().actionSheet().buttons()["Save Note"]

代码:

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");

首先,检查层次结构是否正确。然后,尝试使用"app.popover().actionSheet().buttons()["Save Note"].tap();"如果它对您不起作用,请提供一些关于元素结构/按钮的详细信息。

我认为从javascript访问操作表时存在错误。你可以在这里看到我对类似问题的回答。

基本上,我认为actionSheet()总是对按钮和元素返回nil。这是不应该的,但我所看到的一切都表明情况并非如此。

MikhailV设计了一个函数来点击这里的正确按钮。