1

When Safari is not running, I can open Safari by the following Automation JavaScript code.

safari = Application('Safari')

But when Safari is running and has no windows, the above code does not open Safari's new window.

I tried to add the following code.

window = safari.Window()
safari.windows.push(window)

But no effects.

How can I open new window of Safari by JavaScript Automation when Safari is running but has no windows?

Currently, I am using the following code

safari = Application('Safari')
safari.open(Path('~/dummy'))

I do not like it.

ShooTerKo
  • 2,242
  • 1
  • 13
  • 18
Yuji
  • 614
  • 4
  • 18

1 Answers1

7

You just need Document, not Window.

Safari = Application('Safari');
Safari.Document().make();
fallroot
  • 131
  • 1
  • 3