如何在此路径 "ID#wpbody-content>div.wrap>a" 上编写正确的 getElementBy 并使用 applescript 单击 <a href> 和 javascript
How to write the proper getElementBy on this Path "ID#wpbody-content>div.wrap>a" and click the <a href> using applescript and javascript
我想单击 "a" href 而不是打开要单击的选项卡我将只使用选项卡号 "tab 4"。
试了很多方法都没成功。
我想我没有使用正确的 getElementBy。
这是我的代码
tell application "Safari"
tell tab 2 of window 1 do JavaScript "document.getElementByClassName('wrap').getElementsByTagName('a')[0].href.click;"
end tell
end tell
这里是我的 HTML
div> class="wrap"
h1> class="wp-heading-inline"
a> href="http://versloidejos.lt/wp-admin/post-new.php" class="page-title-action"
hr> class="wp-header-end"
div> div>
div> div>
div> div>
div> div>
form> form>
div>
我要点击"a href"
试试这个:
tell application "Safari"
tell tab 2 of window 1 do JavaScript "document.querySelector('.wrap a').click();"
end tell
end tell
您没有正确使用 JavaScript 方法来点击 link。请检查上面的代码。希望它对你有用。
我想单击 "a" href 而不是打开要单击的选项卡我将只使用选项卡号 "tab 4"。 试了很多方法都没成功。
我想我没有使用正确的 getElementBy。
这是我的代码
tell application "Safari"
tell tab 2 of window 1 do JavaScript "document.getElementByClassName('wrap').getElementsByTagName('a')[0].href.click;"
end tell
end tell
这里是我的 HTML
div> class="wrap"
h1> class="wp-heading-inline"
a> href="http://versloidejos.lt/wp-admin/post-new.php" class="page-title-action"
hr> class="wp-header-end"
div> div>
div> div>
div> div>
div> div>
form> form>
div>
我要点击"a href"
试试这个:
tell application "Safari"
tell tab 2 of window 1 do JavaScript "document.querySelector('.wrap a').click();"
end tell
end tell
您没有正确使用 JavaScript 方法来点击 link。请检查上面的代码。希望它对你有用。