如何找到元素AppleScript的像素位置?

时间:2019-05-04 13:43:38

标签: html applescript

我目前正在制作一个购买机器人,该机器人可以打开一个网站,向购物篮中添加商品,输入结帐信息,然后完成付款。但是,我想向机器人添加一个功能,该功能可在网页上的产品中搜索关键字并标识要单击的关键字的像素位置,然后添加到购物篮中。有人可以帮忙创建代码来搜索和查找关键字以及像素位置。预先感谢!

到目前为止,我已经创建了此代码以在HTML代码中找到关键字,但我需要了解如何找到产品的像素位置。

tell application "Safari"

    set keyword to "Pinstripe"
    repeat
        set myWindow to current tab of first window
        activate

        do JavaScript "window.location.reload()" in myWindow

        repeat while (do JavaScript "document.readyState" in document 1) is not "complete"
            delay 0.5
        end repeat

        set pageContent to do JavaScript ("window.document.documentElement.outerHTML") in myWindow

        if pageContent contains keyword then
            display dialog "found it"
            exit repeat
        end if
        delay 2 -- wait a bit before running again
    end repeat
end tell

0 个答案:

没有答案
相关问题