Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG and temporary fix] Open Firefox as the frontmost window (macOS-specific) #914

Closed
zaydek opened this issue Feb 9, 2020 · 2 comments · Fixed by #923
Closed

[BUG and temporary fix] Open Firefox as the frontmost window (macOS-specific) #914

zaydek opened this issue Feb 9, 2020 · 2 comments · Fixed by #923

Comments

@zaydek
Copy link

zaydek commented Feb 9, 2020

This is both a bug and a temporary fix for Firefox -- ‘Nightly’ on (macOS 10.14.6 / Playwright 0.10.0) opens in the background which is unexpected behavior.

The expected behavior is that Nightly opens as the frontmost window, just the same as with Chromium and WebKit.

Here’s a temporary fix I’m using that is macOS-specific

import { execSync } from "child_process"

// Bring to front:
execSync("osascript -e 'activate application \"Nightly\"'")
// Open as edge-to-edge (for me, my dimensions are 1440px x 900px
execSync(`osascript -e '
	tell application "System Events" to tell process "Nightly"
		set position of window 1 to {0, 0}
		set size of window 1 to {1440, 900}
	end tell
'`)

Note that this requires adding your terminal to System Preferences:

System Preferences
→ Security & Privacy
→ Privacy
→ Accessibility
→ Allow the apps below to control your computer.

You’ll most likely be prompted to do this anyway.

I hope this helps someone!

@zaydek zaydek changed the title [BUG and FIX] Open Firefox as the frontmost window [BUG and temporary fix] Open Firefox as the frontmost window Feb 9, 2020
@zaydek zaydek changed the title [BUG and temporary fix] Open Firefox as the frontmost window [BUG and temporary fix] Open Firefox as the frontmost window (macOS-specific) Feb 9, 2020
@zaydek
Copy link
Author

zaydek commented Feb 9, 2020

Follow-up: I found @pavelfeldman’s comment about how fix the browser args for Firefox removes the need for the second execSync call.

So then you should only need the following to open Firefox as the frontmost window:

import { execSync } from "child_process"

// Bring to front:
execSync("osascript -e 'activate application \"Nightly\"'")

I checked the command-line args for Firefox but didn’t see any official way to do this with a Firefox binary. @digitarald any tip on how to open Firefox as the frontmost window for any OS from the command-line?

@zaydek
Copy link
Author

zaydek commented Feb 14, 2020

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant