๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐Ÿ‘จ๐Ÿผ‍๐Ÿ’ป๊ฐœ๋ฐœ/์…€๋ ˆ๋‹ˆ์›€

์…€๋ ˆ๋‹ˆ์›€ - ๋ชจ๋ฐ”์ผ ์—๋ฎฌ๋ ˆ์ด์…˜ ์˜ต์…˜ ์„ค์ •(ChromiumMobileEmulationDeviceSettings)

by Janger 2022. 11. 15.
728x90
๋ฐ˜์‘ํ˜•
private string ratio(String s)
{
    string result = "360,640,3.0";

    if (s.Contains("SM-N950N"))
        result = "1440,2960,3.5";
    else if (s.Contains("SM-A920N"))
        result = "1440,2960,3.5";
    else if (s.Contains("SM-A5035N"))
        result = "1440,2960,3.5";
    else if (s.Contains("SM-G930N"))
        result = "1440,3040,3.5";
    else if (s.Contains("SM-N960N"))
        result = "1080,2280,3.5";
    else if (s.Contains("SM-A505N"))
        result = "1080,2400,3.5";
    else if (s.Contains("SM-M205N"))
        result = "1440,3088,3.5";
    else if (s.Contains("SM-G975N"))
        result = "1440,3200,3.5";
    else if (s.Contains("SM-G973N"))
        result = "1440,3040,3.5";
    else if (s.Contains("SM-N971N"))
        result = "1440,2960,3.5";
    else if (s.Contains("SM-N981N"))
        result = "1440,3040,3.5";
    else if (s.Contains("SM-N986N"))
        result = "1080,2280,3.5";
    else if (s.Contains("SM-A135N"))
        result = "1080,2400,3.5";
    else if (s.Contains("SM-E426N"))
        result = "1080,2280,3.5";
    else if (s.Contains("SM-G988N"))
        result = "1080,2400,3.5";
    else
        result = "1080,2400,3.5";
    return result;

}

var options = new ChromeOptions();

string size = ratio(userAgent);
var mobileEmulationSettings = new ChromiumMobileEmulationDeviceSettings
{
    UserAgent = userAgent,
    Width = (int)(float.Parse(size.Split(',')[0]) / float.Parse(size.Split(',')[2])),
    Height = (int)(float.Parse(size.Split(',')[1]) / float.Parse(size.Split(',')[2])),
    EnableTouchEvents = true,
    PixelRatio = float.Parse(size.Split(',')[2]),
};
options.EnableMobileEmulation(mobileEmulationSettings);

 

ChromeMobileEmulationDeviceSettings CMEDS = new ChromeMobileEmulationDeviceSettings();
CMEDS.Width = 66;
CMEDS.Height = 37;
CMEDS.PixelRatio = 1.0;
CMEDS.UserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25";

ChromeOptions chromeCapabilities = new ChromeOptions();

chromeCapabilities.EnableMobileEmulation(CMEDS);

 

์ถœ์ฒ˜: 

https://stackoverflow.com/questions/36338760/c-sharp-selenium-mobile-emulation-in-landscape

 

C# Selenium Mobile Emulation in landscape

I'm doing some mobile UI testing using Selenium in a .Net environment using c#. I'm able to do testing quite successfully using the chrome mobile emulation in portrait mode, but I can not found ho...

stackoverflow.com

 

728x90
๋ฐ˜์‘ํ˜•