WebDriver simulate touch events in Desktop Browser

China☆狼群 提交于 2019-12-08 08:37:14

问题


I'm trying to simulate some touch events like swap, tap in web-based application using Chrome and Firefox browsers. I've tried to simulate touch events with Actions, Hummber.js, "Yahoo" lib(YUI) but none of them works for me.

What is the best way to simulate touch events with webdriver in desktop browsers?


回答1:


I'm using phantom limb which transforms mouse events to touch events. It worked for me. I thing the best way to simulate touch events in Chrome is to use built-in emulations mechanism. Like in this article. Unfortunately I can't find the way to turn on this feature by webdriver. Found the Chrome options like "enable-touch-events", "touch-events" and etc. But it didn't worked.

UP: Chrome Driver allows to emulate chrome browser on mobile device. Read this article.




回答2:


With jQueryMobile it is quite simple, I execute some Javascript which trigger the corresponding touch events from jQueryMobile.

((JavascriptExecutor)driver).executeScript("window.jQuery('#myId').trigger('swiperight')");

Maybe that helps.



来源:https://stackoverflow.com/questions/15479143/webdriver-simulate-touch-events-in-desktop-browser

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!