Applescript正在等待加载页面
Applescript waiting for a page to load
在继续执行appscriptive之前,我已经尝试了各种解决方案来轮询elementID。我宁愿投票,也不愿随意拖延。
set pageNotLoaded to true
set doForThisID to do JavaScript "document.getElementById(‘thisElementID‘);"
repeat while pageNotLoaded is true
try
if (doForThisID contains "thisElementID") then
set pageNotLoaded to false
end if
end try
end repeat
我尝试过网上提供的各种解决方案,但都无济于事。有人能为这个代码提供一些建议吗?
您的一些逻辑不正常,会使事情变得混乱。此外,最好的做法是让javascript通过嵌套.contents来传递布尔值
javascript文档.readyState
一个javascript文档。包含
对文档文本进行简单的Safari调用以查找字符串。
您可以更改此脚本以仅使用其中一个。
property testingID : "login"
property testingString : "Username:"
set pageLoaded to false
tell application "Safari"
repeat while pageLoaded is false
set readyState to (do JavaScript "document.readyState" in document 1)
set foundID to (do JavaScript "document.contains(document.getElementById(" & quoted form of testingID & "))" in document 1)
set pageText to text of document 1
if (readyState is "complete") and (foundID is true) and (pageText contains testingString) then set pageLoaded to true
delay 0.2
end repeat
end tell
display dialog "Ready state of page: " & readyState & return & ¬
"ID is loaded: " & foundID & return & ¬
"Test string is loaded: " & testingString
相关文章:
- Emberjs应用程序加载在除Index之外的所有路由上
- 如何删除视频's缩略图时's加载在JW Player's闪光模式
- document.images未加载在chrome或firefox上,但已加载在IE上
- Cordova包装应用程序内部链接加载在应用程序中,外部链接加载在浏览器中
- 如何让我的网站上的WEBP图像加载在morzilla firefox中有一个可能的解决方案吗?如果是,那么如何
- angularjs-ui路由器父状态,参数加载在子状态之后
- 如何检查iframe是否加载在JavaScript中
- 如何使AngularJS控制器依赖于通过ajax加载在rootScope上的值
- Javascript:Google Maps API:如果地图加载在隐藏容器中,则为空白地图
- WooCommerce CSS和Checkout按钮未加载在单个产品页面中
- 加载在JSBN中创建的RSA公钥,然后加密消息
- 为什么动画设置加载在TweenMax中的两个单独的对象文字中
- IE错误,视频加载在颜色框中
- jQuery加载在Dreamweaver上有效,但在浏览器中无效
- 正在显示加载..在将新图像加载到网站时播放动画
- 图像预加载在另一个函数中
- 打开一个模态(在Codeigniter中),该模态从依赖于phpvar的URL加载(在iframe中)内容
- YouTube Javascript API:加载在 Firefox 中不起作用
- 如何等待,直到图像加载在jquery
- 显示等待弹出时,页面加载在母版页