Skip to content

Instantly share code, notes, and snippets.

@Johnz86
Created October 21, 2015 10:36
Show Gist options
  • Save Johnz86/e865a0851c2a255f2902 to your computer and use it in GitHub Desktop.
Save Johnz86/e865a0851c2a255f2902 to your computer and use it in GitHub Desktop.
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);
}
}
@dilpreetbadwal
Copy link

I used your code . Firefox opens in the mobile mode , but in default size and not the size specified in setViewSize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment