Указание агента пользователя при использовании chrome довольно просто, как показано ниже:
Behat\MinkExtension:
base_url: https://example.com/
selenium2:
# ===== configuration for chrome =====
browser: chrome
capabilities:
extra_capabilities:
chromeOptions:
args:
- "--user-agent=Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36"
trustAllSSLCertificates: true
acceptSslCerts: true
proxy:
proxyType: "manual"
httpProxy: "proxy_host.com:123"
sslProxy: "proxy_host.com:123"
Принимая во внимание, что установка агента пользователя в firefox является сложной задачей.
Используйте следующие команды для указания пользовательского агента в формате zip в CentOs:
# Creating custom profile for firefox to set mobile user agent
yum install -y zip
mkdir -p /example_path/firefox-profile/
echo 'user_pref("general.useragent.override", "Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36");' >> /example_path/firefox-profile/prefs.js
# prefs.js should be in the root of the archive
zip -rj /example_path/firefox-profile.zip /example_path/firefox-profile/*
rm -rf /example_path/firefox-profile/
А затем укажите созданный профиль firefox в behat.yml:
Behat\MinkExtension:
base_url: https://example.com/
selenium2:
# ===== configuration for firefox =====
browser: firefox
capabilities:
firefox:
# custom profile set for mobile user agent
profile: /example_path/firefox-profile.zip
extra_capabilities:
trustAllSSLCertificates: true
acceptSslCerts: true
proxy:
proxyType: "manual"
httpProxy: "proxy_host.com:123"
sslProxy: "proxy_host.com:123"