How to make chrome mobile emulation open an h5 page with drag ability?

13 views
Skip to first unread message

QunXuan Li

unread,
May 12, 2018, 3:53:08 AM5/12/18
to Selenium Users


Dear All:


When I open an browser and click Ctrl + Shift +I  or F12, then I click "Toggle device toolbar" button or Ctrl + Shift + M. I get following screen.  


Pay attention to the bigger red box. The grey circle is my mouse cursor.  I can drag the page on this mode.




But when I open browser by mobile emulation as following java code, I get a page without drag ability.


Who knows how to make it can be dragged by code? 




System.setProperty("webdriver.chrome.driver", userPath + sSeperator + "drivers\\chromedriver.exe");

Map<String, Object> mobileEmulation = new HashMap<String, Object>();    

mobileEmulation.put("deviceName", "iPhone X"); 


Map<String, Object> chromeOptions = new HashMap<String, Object>();       

chromeOptions.put("mobileEmulation", mobileEmulation);       

DesiredCapabilities capabilities = DesiredCapabilities.chrome();         

capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions);   

           

WebDriver driver=new ChromeDriver(capabilities);  

         

driver.get("https://m.xxx.com/");

driver.manage().window().maximize();








Thanks a lot !




Reply all
Reply to author
Forward
0 new messages