setting userAgent and touch events

29 views
Skip to first unread message

Trevor Pering

unread,
Feb 8, 2014, 1:00:21 PM2/8/14
to chromedev...@googlegroups.com
Hello, I'm working on a small project that needs to control a desktop instance of Chrome using touch events. I'm using the remote debug protocol defined at https://developers.google.com/chrome-developer-tools/docs/debugger-protocol -- and in order to accomplish what I want to do I need two capabilities, listed below.  I've been successful in writing a small Java stub API using web-sockets for what I need, since I wanted higher performance than using POST calls and chromedriver doesn't seem to support touch events for desktop.  I've been successful overall for the most part -- I can initiate a connection and send touch events just fine.  But there are two things I need to do that I'm having some trouble with:

1) Sometimes change the userAgent -- for a variety of reasons, sometimes I need a desktop user agent, while sometimes I need a tablet user agent. I'd like to do this using the debug protocol, rather than a command-line flag. For whatever reason, I can't get the Network.setUserAgentOverride call to work.  It just doesn't do anything. I've looked at the WS communication used by running a remote browser to control the target browser, and I've tried copying the message exactly, but it just doesn't work.  When I use my API call, it returns a valid result (no error), but the user agent doesn't change when I navigate to a new page.  Any thoughts on how this is supposed to work or debugging tips on how to figure out what is going wrong?

The request I'm sending is: { "id": 1, "method": "Network.setUserAgentOverride", "params": { "userAgent": "...long iPad user agent string here..." } }

2) Send touch events to the browser -- I figured out how to get this working, but as far as I can tell I'm using an undocumented API.  By browsing through the source for something (can't remember what), I figured out to use the "Input.dispatchTouchEvent" method -- and it works great.  I'm just confused as to why it's not documented and/or why it's not supported in chromedriver for desktop systems (the class doesn't implement the HasTouchScreen interface... I suppose the other path for what I need to do would be to figure out how to add the HasTouchScreen interface to chromedriver Java SDK, but I wasn't sure about how to go about doing that, and then there's also the performance consideration (POST vs. WebSocket).

Any thoughts?

Cheers,
  Trevor


Reply all
Reply to author
Forward
0 new messages