I've run into the following problem while attempting to emulate a mobile browser with chrome on heroku: Selenium ERR_NAME_NOT_RESOLVED on heroku with mobile testing. Based on Josh Lewis's answer, and the python code sample at https://sites.google.com/a/chromium.org/chromedriver/mobile-emulation
from selenium import webdriver
mobile_emulation = { "deviceName": "Nexus 5" }
chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("mobileEmulation", mobile_emulation)
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities = chrome_options.to_capabilities())
It may be that I need to use a command_executor (defined at https://seleniumhq.github.io/selenium/docs/api/py/webdriver_remote/selenium.webdriver.remote.webdriver.html) as
command_executor - Either a string representing URL of the remote server or a
custom
remote_connection.RemoteConnection object. Defaults to
‘http://127.0.0.1:4444/wd/hub'
to get my code working. How would I found this with the Heroku chrome buildpack, https://github.com/heroku/heroku-buildpack-google-chrome
edit:
You can download my project for both windows and heroku use at:
https://github.com/kc1/mobiletest
(keep in mind that if you deploy to heroku you have to set FLASK_CONFIG to production. )