Created
October 21, 2015 10:36
-
-
Save Johnz86/e865a0851c2a255f2902 to your computer and use it in GitHub Desktop.
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
package web.acceptance.utility; | |
import org.openqa.selenium.Keys; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.firefox.FirefoxProfile; | |
import org.openqa.selenium.interactions.Actions; | |
public class FirefoxResponsiveMode { | |
public static void pressShortcut(WebDriver driver) { | |
Actions actions = new Actions(driver); | |
actions.keyDown(Keys.CONTROL).keyDown(Keys.SHIFT).sendKeys("m").keyUp(Keys.SHIFT).keyUp(Keys.CONTROL).perform(); | |
} | |
public static void setViewSize(FirefoxProfile profile, String viewDeviceName, Integer width, Integer height) { | |
String responsiveMode = | |
"[{\"width\": " + width + ", \"name\": \"" + viewDeviceName + "\", \"key\": \"" + width + "x" + height + "\", \"height\": " | |
+ height + "}]"; | |
profile.setPreference("devtools.responsiveUI.presets", responsiveMode); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I used your code . Firefox opens in the mobile mode , but in default size and not the size specified in setViewSize