All Downloads are FREE. Search and download functionalities are using the official Maven repository.

driverfactory.webdriver.helpers.MobileEmulation Maven / Gradle / Ivy

Go to download

An open-source Selenium Java-based Test automation Framework that allows you to perform multiple actions to test a web application's functionality, behaviour, which provides easy to use syntax, and easy to set up environment according to the needed requirements for testing

There is a newer version: 1.1.1
Show newest version
package driverfactory.webdriver.helpers;

import tools.properties.Properties;
import utilities.LoggingManager;

import java.util.HashMap;
import java.util.Map;


public class MobileEmulation {

    private MobileEmulation() {

    }

    public static Map setEmulationSettings() {

        Map mobileEmulation = new HashMap<>();
        if(Properties.web.isCustomDevice()){
            Map deviceMetrics = new HashMap<>();
            deviceMetrics.put("width", Properties.web.customDeviceWidth());
            deviceMetrics.put("height", Properties.web.customDeviceHeight());
            deviceMetrics.put("pixelRatio", Properties.web.customDevicePixelRatio());
            mobileEmulation.put("deviceMetrics", deviceMetrics);
            mobileEmulation.put("userAgent",
                    "Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19");
            LoggingManager.info("Running Mobile Emulation via Custom Device");
            LoggingManager.info("Screen size: " + Properties.web.customDeviceWidth() + "x"
                    + Properties.web.customDeviceHeight());
            LoggingManager.info("Screen Pixel Ratio: " + Properties.web.customDevicePixelRatio());
        }
        else {
            mobileEmulation.put("deviceName", Properties.web.deviceName());
            LoggingManager.info("Running Mobile Emulation via " + Properties.web.deviceName());
        }

        return mobileEmulation;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy