Skip to content

Instantly share code, notes, and snippets.

@natritmeyer
Created April 20, 2012 10:16
Show Gist options
  • Save natritmeyer/2427601 to your computer and use it in GitHub Desktop.
Save natritmeyer/2427601 to your computer and use it in GitHub Desktop.
Example ruby/applescript combo that brings browsers to the front - useful in browser test automation...
#you probably only need one of these, but here's the lot of them...
#prepare the commands that will bring the various browsers to the front
bring_chrome_to_front = %Q{ osascript -e "tell application \\\"Google Chrome\\\" to activate" }
bring_firefox_to_front = %Q{ osascript -e "tell application \\\"Firefox\\\" to activate" }
#execute the applescript commands to bring the browsers to the front
`#{bring_chrome_to_front}`
`#{bring_firefox_to_front}`
#prepare the commands that will resize the various browser
resize_chrome_window = %Q{osascript -e "tell application \\\"Google Chrome\\\" to set bounds of window 1 to {1,1,1300,740}"}
resize_firefox_window = %Q{osascript -e "tell application \\\"Firefox\\\" to set bounds of window 1 to {1,1,1300,740}"}
#execute the commands to resize the browser window
`#{resize_chrome_window}`
`#{resize_firefox_window}`
bring_chrome_to_front = %Q{ osascript -e "tell application \\\"Google Chrome\\\" to activate" }
`#{bring_chrome_to_front}`
resize_chrome_window = %Q{osascript -e "tell application \\\"Google Chrome\\\" to set bounds of window 1 to {1,1,1300,740}"}
`#{resize_chrome_window}`
bring_firefox_to_front = %Q{ osascript -e "tell application \\\"Firefox\\\" to activate" }
`#{bring_firefox_to_front}`
resize_firefox_window = %Q{osascript -e "tell application \\\"Firefox\\\" to set bounds of window 1 to {1,1,1300,740}"}
`#{resize_firefox_window}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment