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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

QunXuan Li


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 !




--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/0c8f3e46-4436-4aba-8fa3-af7b8cabd715%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.