Вы можете показать это на примере?
Вам нужно указать его в секции capabilities
конфига. Ознакомьтесь с этим документом, чтобы узнать, как создать конфигурацию JSON для прокси-серверов webdriver: https://code.google.com/p/selenium/wiki/DesiredCapabilities#Proxy_JSON_Object
Пробовал, у меня не получилось. Это могло быть из-за моей неопытности. У вас или у кого-нибудь есть небольшой пример, который вы можете показать? Это будет долгий путь.
capabilities: {
'proxy': {
'proxyType': 'manual',
'httpProxy': 'hostname.com:1234'
}
}
Это решение не работает для нашей установки. Есть идеи, что я делаю не так? При попытке запустить транспортир в командной строке появляется следующая ошибка:
> Fatal error: protractor exited with code: 1
Вот мой файл конфигурации:
// A reference configuration file.
exports.config = {
// ----- How to setup Selenium -----
//
// There are three ways to specify how to use Selenium. Specify one of the
// following:
//
// 1. seleniumServerJar - to start Selenium Standalone locally.
// 2. seleniumAddress - to connect to a Selenium server which is already
// running.
// 3. sauceUser/sauceKey - to use remote Selenium servers via SauceLabs.
// The location of the selenium standalone server .jar file.
seleniumServerJar: './selenium/selenium-server-standalone-2.35.0.jar',
// The port to start the selenium server on, or null if the server should
// find its own unused port.
seleniumPort: null,
// Chromedriver location is used to help the selenium standalone server
// find chromedriver. This will be passed to the selenium jar as
// the system property webdriver.chrome.driver. If null, selenium will
// attempt to find chromedriver using PATH.
chromeDriver: './selenium/chromedriver',
// Additional command line options to pass to selenium. For example,
// if you need to change the browser timeout, use
// seleniumArgs: ['-browserTimeout=60'],
seleniumArgs: [],
// If sauceUser and sauceKey are specified, seleniumServerJar will be ignored.
// The tests will be run remotely using SauceLabs.
sauceUser: null,
sauceKey: null,
// ----- What tests to run -----
//
// Spec patterns are relative to the location of this config.
specs: [
'./e2e/*-spec.js'
],
// ----- Capabilities to be passed to the webdriver instance ----
//
// For a full list of available capabilities, see
// https://code.google.com/p/selenium/wiki/DesiredCapabilities
// and
// https://code.google.com/p/selenium/source/browse/javascript/webdriver/capabilities.js
capabilities: {
'browserName': 'chrome',
'proxy': {
'proxyType': 'manual',
'httpProxy': 'https://localhost.com:8443/'
}
},
// A base URL for your application under test. Calls to protractor.get()
// with relative paths will be prepended with this.
baseUrl: 'http://localhost:9999',
// Selector for the element housing the angular app - this defaults to
// body, but is necessary if ng-app is on a descendant of <body>
rootElement: 'body',
// ----- Options to be passed to minijasminenode -----
jasmineNodeOpts: {
// onComplete will be called just before the driver quits.
onComplete: null,
// If true, display spec names.
isVerbose: true,
// If true, print colors to the terminal.
showColors: true,
// If true, include stack traces in failures.
includeStackTrace: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 10000
}
};
Я попробовал ваши возможности, и у меня это работает. Когда я вставляю поддельный httpProxy, я вижу в браузере ошибки «не удалось подключиться к прокси», но тесты все равно пытаются запустить. Правильно ли работают ваши тесты без прокси? Как они терпят неудачу в таком случае?
Хорошо, я обнаружил, что действительно работает, это просто установить baseurl на сайт тестирования https, например:
exports.config = {
seleniumServerJar: './selenium/selenium-server-standalone-2.35.0.jar',
seleniumPort: null,
chromeDriver: './selenium/chromedriver',
seleniumArgs: [],
sauceUser: null,
sauceKey: null,
specs: [
'./e2e/*-spec.js'
],
capabilities: {
'browserName': 'chrome'
},
baseUrl: 'https://localhost:8443/',
rootElement: 'body',
jasmineNodeOpts: {
// onComplete will be called just before the driver quits.
onComplete: null,
// If true, display spec names.
isVerbose: true,
// If true, print colors to the terminal.
showColors: true,
// If true, include stack traces in failures.
includeStackTrace: true,
// Default time to wait in ms before a test fails.
defaultTimeoutInterval: 10000
}
};
Привет,
Мне удалось заставить прокси-сервер работать с тем, что вы здесь сделали, так что спасибо за это, теперь я хочу добавить переменную noProxy, чтобы я мог исключить мои внутренние службы от перехода на прокси. Я пробовал следующее, но часть noProxy не используется. Я использую PhantomJs.
'proxy': {
'proxyType': 'manual',
'httpProxy': 'http://proxy.blah.co.uk:8080'
'httpsProxy': 'http://proxy.blah.co.uk:8080'
'noProxy': 'blah.blah.co.uk,*blah.blah.co.uk,.blah.blah.co.uk'
}
},
Привет,
Я не мог заставить его работать с аутентифицированным прокси. Я пытался:
'proxy': {
'proxyType': 'manual',
'httpProxy': 'user:[email protected]:3128'
'sslProxy': 'user:[email protected]:3128'
}
и
'proxy': {
'proxyType': 'manual',
'httpProxy': 'http://user:[email protected]:3128'
'sslProxy': 'http://user:[email protected]:3128'
}
Я пытаюсь завершить https://docs.angularjs.org/tutorial/step_03 , используя браузер Chrome.
У меня тоже не работает - мне нужно указать host: port вместе с именем пользователя / паролем, я попробовал все вышеперечисленные предложения, и, похоже, ничего не работает. Однако, когда я выхожу из корпоративного Интернета и пробую без прокси, все работает нормально. Любая помощь?
Собственно моя проблема решилась настройкой системных переменных
http_proxy http://user:password<strong i="6">@proxy_url</strong>:port
https_proxy http://user:password<strong i="7">@proxy_url</strong>:port
Это необходимо повторно открыть здесь, в GE Software, установка http_proxy и https_proxy в конфигурации по-прежнему не позволяет Protractor отправлять Saucelabs окончательный код выхода результатов теста, что приводит к тому, что Saucelabs не проходит тест из-за бездействия.
@jonniespratley вам не подходит protractor config --proxy=http://user:password<strong i="6">@proxy_url</strong>:port
?
Я попытался запустить тест транспортира в лаборатории соуса, но получил ошибку ETIMEDOUT. Я нахожусь за корпоративным брандмауэром, и я настроил прокси в файле конфигурации транспортира и переменной среды. Конфигурация не работает. Ниже я получаю ошибку
Error: ETIMEDOUT connect ETIMEDOUT 151.444.33.22:80
at ClientRequest.<anonymous> (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/http/index.js:174:16)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at doNTCallback2 (node.js:439:9)
at process._tickCallback (node.js:353:17)
From: Task: WebDriver.createSession()
at Function.webdriver.WebDriver.acquireSession_ (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:157:22)
at Function.webdriver.WebDriver.createSession (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:131:30)
at [object Object].Builder.build (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/selenium-webdriver/builder.js:445:22)
at [object Object].DriverProvider.getNewDriver (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/driverProviders/driverProvider.js:42:27)
at [object Object].Runner.createBrowser (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/runner.js:190:37)
at /Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/lib/runner.js:280:21
at _fulfilled (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:834:54)
at self.promiseDispatch.done (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:863:30)
at Promise.promise.promiseDispatch (/Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:796:13)
at /Users/user123/Desktop/Sample/example-sandbox/node_modules/protractor/node_modules/q/q.js:556:49
[launcher] Process exited with error code 1
Есть идеи? Я буду очень признателен за помощь.
Я получаю похожие ошибки. Я использую корпоративный прокси и не могу отправить тест в стек браузера.
/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/promise.js:654
throw error;
^
Error: ETIMEDOUT connect ETIMEDOUT 208.52.180.201:80
at ClientRequest.<anonymous> (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/http/index.js:381:15)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:259:9)
at emitOne (events.js:77:13)
at Socket.emit (events.js:169:7)
at emitErrorNT (net.js:1253:8)
at doNTCallback2 (node.js:441:9)
at process._tickCallback (node.js:355:17)
From: Task: WebDriver.createSession()
at Function.createSession (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:329:24)
at Builder.build (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/builder.js:458:24)
at Object.<anonymous> (/Users/Documents/coding/sublime/simpleboilerplate/bs.js:13:3)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
at node.js:963:3
From: Task: WebDriver.navigate().to(http://www.google.com)
at WebDriver.schedule (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:377:17)
at Navigation.to (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:1027:25)
at WebDriver.get (/Users/Documents/coding/sublime/simpleboilerplate/node_modules/selenium-webdriver/lib/webdriver.js:795:28)
at Object.<anonymous> (/Users/Documents/coding/sublime/simpleboilerplate/bs.js:15:8)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Function.Module.runMain (module.js:467:10)
at startup (node.js:136:18)
Что, наконец, помогло нам выйти из нашего корпоративного прокси и перейти на селен-сервер perfecto mobile, было использование конфигурации webDriverProxy
:
exports.config = {
framework: 'jasmine',
seleniumAddress: 'https://yourCloudName.perfectomobile.com/nexperience/perfectomobile/wd/hub',
webDriverProxy: 'http://your.proxy.here:8080',
capabilities: { ... },
specs: ['myspec.js']
};
Я работаю за корпоративным прокси, пытался добавить этот код в conf.js
'proxy': {
'proxyType': 'руководство',
'httpProxy': ' пользователь: пароль@proxy.blah.co.uk: 8080'
'sslProxy': ' пользователь: пароль@proxy.blah.co.uk: 8080'
}
он работал нормально, но время выполнения приложения увеличилось, что привело к сбою. Да, я могу увеличить время по умолчанию, но я не хочу, чтобы мое приложение выполняло больше времени.
Может ли кто-нибудь помочь мне это исправить.
Заранее спасибо.
@gregjacobs Я также использую webDriverProxy с perfecto. Некоторое время назад это работало для меня. После обновления до 4.x или 5.x я больше не мог заставить его работать. После обновления он все еще работает?
Ни один из вариантов прокси из https://github.com/angular/protractor/blob/master/lib/config.ts не работает для меня. Кому-нибудь повезло с настройкой прокси в v5?
@ Deli6z
Установил прокси BrowserMob и транспортир с этими возможностями - отлично работает
capabilities: {
'browserName': 'chrome',
'args': ['disable-web-security'],
'proxy': {
'proxyType': 'manual',
'httpProxy': '10.179.70.127:10801',
'sslProxy': '10.179.70.127:10801',
"autodetect": 'false'
}
}
@gregjacobs Мне нужно указать имя пользователя / пароль для нашего прокси, используемого в свойстве webDriverProxy
. Ты знаешь как?
@ luker2 К сожалению, я не совсем уверен, но webDriverProxy: 'http://username:[email protected]:8080'
не работает? (где 8080
- порт вашего прокси?)
@gregjacobs да, я еще не следил, но это то, что в итоге сработало!
Для других мне также пришлось закодировать URL-адрес части имени пользователя: пароля, чтобы избежать специальных символов ...
webDriverProxy: `http://${encodeURIComponent(username)}:${encodeURIComponent(password)}@your.proxy.here:8080`
@ luker2 Замечательно , рад слышать, что у вас все заработало! И спасибо за публикацию статьи о кодировке uri имени пользователя и пароля - хороший улов!
Самый полезный комментарий