Last active
December 23, 2015 13:05
-
-
Save kazuki-ma/3601f949bf2e8160639b to your computer and use it in GitHub Desktop.
Safari Responsive Design Mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.AWTException; | |
import java.awt.Robot; | |
import java.awt.event.KeyEvent; | |
import java.io.IOException; | |
import lombok.Cleanup; | |
import org.openqa.selenium.safari.SafariDriver; | |
public class SafariCustomDriverProvider { | |
public static void main(String[] args) throws InterruptedException, IOException { | |
// Safari Driver 起動 | |
@Cleanup("quit") | |
final SafariDriver driver = new SafariDriver(); | |
// Safari Window を Screen Top に | |
Runtime.getRuntime().exec("open -a /Applications/Safari.app/Contents/MacOS/Safari").waitFor(); | |
// Option + Command + R で Responsive Desing モード起動 | |
try { | |
final Robot robot = new Robot(); | |
robot.keyPress(KeyEvent.VK_ALT); | |
robot.keyPress(KeyEvent.VK_META); | |
robot.keyPress(KeyEvent.VK_R); | |
robot.delay(100); | |
robot.keyRelease(KeyEvent.VK_ALT); | |
robot.keyRelease(KeyEvent.VK_META); | |
robot.keyRelease(KeyEvent.VK_R); | |
} catch (AWTException e) { | |
throw new RuntimeException(e); | |
} | |
driver.get("http://example.com/"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gyazo.com/a6d6898f29dbd218df5d3dbdbc76b50c