Мне нужно установить и настроить расширение в Chrome, чтобы изменить все заголовки запросов во время выполнения теста Selenium. Я смог следовать примеру этой статьи поддержки в Saucelabs, показывающей, как это сделать для Firefox на местном уровне, но не уверен, как это сделать поэтому для Chrome.
Документация ChromeDriver для extensions включает только их установку, а не настройку.
Вопросы
- Может ли кто-нибудь указать мне на некоторые документы, которые объясняют, как это можно сделать или разместить пример здесь?
- Как будут обновляться настройки?
- Как узнать, какие свойства настроек доступны для любого данного расширения?
- Существуют ли какие-либо различия между локальным и удаленным выполнением с той одной из проблем, с которой я столкнулся с методом Firefox?
План - запустить это против SauceLabs. Попробуем использовать расширение ModHeader для установки необходимых значений заголовка.
РЕДАКТИРОВАТЬ 1
Пробовал установку версии расширения ModHeader в Chrome, но столкнулся с аналогичными проблемами. Возможность получить расширение, установленное локально, но в удаленных версиях см. Сообщение об ошибке.
private static IWebDriver GetRemoteDriver(string browser)
{
ChromeOptions options = new ChromeOptions();
options.AddExtensions("Tools/Chrome_ModHeader_2_0_6.crx");
DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability(ChromeOptions.Capability, options);
capabilities.SetCapability("name", buildContext);
capabilities.SetCapability(CapabilityType.BrowserName, "Chrome");
capabilities.SetCapability(CapabilityType.Version, "");
capabilities.SetCapability(CapabilityType.Platform, "Windows 10");
capabilities.SetCapability("screen-resolution", "1280x1024");
capabilities.SetCapability("username", "SaucelabsUserName");
capabilities.SetCapability("accessKey", "SaucelabsAccessKey");
capabilities.SetCapability("build", "BuildNumber");
capabilities.SetCapability("seleniumVersion", "2.50.1");
return new RemoteWebDriver(new Uri("http://ondemand.saucelabs.com/wd/hub"), capabilities);
}
Ошибка, отображаемая в журналах SauceLabs,
[1.968][INFO]: RESPONSE InitSession unknown error: cannot parse capability: chromeOptions
from unknown error: unrecognized chrome option: Arguments