I use this to open a link (the url is unknown):

tell application "Google Chrome"
    tell tab 1 of window 1 to set OpenfirstTab to execute javascript "document.getElementById('TransactionHistory').click();
end tell

is there a way to have AppleScript to open in a new tab, in the background using the javascript with not known URL

my workaround for now is to duplicate the first page and open the link on the duplicated page, by the website don't handle that very well and it's not always working

  • Have a look at the accepted answer to How to open a new tab in Background in Chrome using AppleScript. Technically it is not opening the new tab in the background however it acts as though it is. – user3439894 Mar 22 '18 at 0:47
  • Sorry I didnt wrote my post properly, I'll will edit it, I know how to open a new tab when I know the url, but I'm not sure how to do using getelementbyid().clock – Kevin Mar 22 '18 at 9:48
  • If what you mean by "in the background" is the tab opening the "not known URL" is not the active tab then the methodology used in the answer linked in my first comment is still applicable, you just have to modify the code to fit the usage. BTW Why are you using a linefeed after ...click(); so that the " is on the next line and not directly after ...click();, e.g. ...click();" as I believe it should be? – user3439894 Mar 22 '18 at 11:21
  • Yes you are correct for the click();", writing mistake but that was working alright, I fixed it anyway. I don't understand though how can I ".click();" and have the link open in a another tab? – Kevin Mar 23 '18 at 10:41

You must log in to answer this question.

Browse other questions tagged .