python - Why does PhantomJS on Ubuntu register as a touch device by Google Maps? -


Fastdownmaj incompatible between Ubuntu & amp; Mac is recognized by Google Maps as a touch device on Ubuntu

I recently stumbled across the operating system to look like an inconsistency in PhantamJS.

To test Python 2.7 website applications, selenium module (2.42.1) and funmoz (1.9.7). While testing a webpage using Google Maps JS API 3, I found that Google Maps recognizes FantomJs as a touch device on Ubuntu, but is not weird on Mac.

I have put together a simple one.

What happens is that the zoom control buttons look different on touch devices like iOS or Android devices, they grow up and go to the bottom left corner.

Run the following Python script

  # - * - Coding: UTF-8 - * - Selenium Import WebDriver from Import OS, Time Browser = WebDriver. FanTomS (service_log_path = os.path.devnull) browser.set_window_size (1280, 800) Browser.get ("https://notendur.hi.is/~sfg6/google_maps_example/") time.sleep (5) browser. Save_screenshot ('Test_google_maps_api_screenshot.png')   

lets me but.

Can I stop PhantomJS from being registered as a touch device in any way?


Answer:

As suggested by Jeff Sisan in the response given below, the user agent string

Phantom JS used the following user agent string on Ubuntu:

  Mozilla / 5.0 (unknown; Linux x86_64) Apple WebKit / 534.34 (KHTML like guitar) PhantomJS / 1.9.7 Safari / 534.34   

And this one on Mac:

  Mozilla / 5.0 (Macintosh; Intel Mac OS X 10_7_5) Apple WebKit / 537.36 After trying some other stuff I came to the conclusion that the problem was the stage token below (like KHML, GECO) Chrome / 36.0.1 9 85.125 Safari / 537.36   

As shown in the example after the change Unknown , Google Maps has PhantomJS fend off as the mobile device.

  # - * - coding: Utf-8 - * - Selenium Import from WebDrive to selenium.webbritter.com.Disdairdabibilites import, import the desired capabilities oops, time dcap = dict (desirable capabilities .phantomjs) dcap ["phantomjs.page.settings.userAgent"] = ("Mozilla / 5.0 (X11; Linux x86_64) Apple WebCat / 534.34" "(KHML, like Gikko) FontemJs / 1.9.7 Safari / 534.34") Browser = WebDriver Fontmose (desired_capttion = DAP, service_log_path = OS path.devnull) browser.set_window_size (1280, 800) browser.get ("https://notendur.hi.is/~sfg6/google_maps_example/") time.sleep (5) Browser. Save_screenshot ('test_google_maps_api_screenshot_x11.png')   

Running on Python script on Ubuntu.

Have you tried setting the user agent of the phantom manually? Anecdotally (using Safari on a Mac), your test page loads the mobile user when I set the user agent on the iPhone, then this could be a simple case of sniffing the wrong browser.

You can set the user code with page.settings :

This example will also be logged that what is the default user agent ??? And it seems that the user agent is definitely different between the operating system.

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -