Protractor: 構成でプロキシサーバーを指定する方法はありますか?

作成日 2013年09月28日  ·  24コメント  ·  ソース: angular/protractor

question

最も参考になるコメント

capabilities: {
  'proxy': {
    'proxyType': 'manual',
    'httpProxy': 'hostname.com:1234'
  }
}

全てのコメント24件

この例を示していただけますか?

構成のcapabilitiesセクションで指定する必要があります。 WebドライバープロキシのJSON構成を作成する方法については、次のドキュメントを確認してください: 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部分が使用されていません。 PhantomJを使用しています。

  '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'
}

ブラウザChromeを使用して、 https://docs.angularjs.org/tutorial/step_03を完了しようとしてい

私にとっても機能しません-ユーザー名/パスワードと一緒に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

これを再度開く必要があります。ここGESoftwareで、構成にhttp_proxyとhttps_proxyを設定しても、ProtractorはSaucelabsにテスト結果の最終終了コードを送信できず、Saucelabsは非アクティブのためにテストに失敗します。

@jonniespratleyprotractor 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

何か案が? 私は本当に助けに感謝します。

同様のエラーが発生します。 私は企業プロキシの背後にいて、browserstackにテストを送信できません。

/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にこのコードを追加しようとしました
'プロキシ':{
'proxyType': 'manual'、
'httpProxy': ' user:[email protected] :8080'
'sslProxy': ' user:[email protected] :8080'
}

正常に動作していましたが、アプリケーションの実行時間が長くなり、結果が失敗しました。はい、デフォルトの時間を増やすことはできますが、アプリケーションの実行に時間がかかりたくありません。
誰かが私がこれを修正するのを手伝ってくれますか?

前もって感謝します。

@gregjacobs私は

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はい、まだフォローアップしていませんでしたが、それがうまくいきました!

他の人のために、私はまた、特殊文字をエスケープするために、 username:password部分をURLエンコードする

webDriverProxy: `http://${encodeURIComponent(username)}:${encodeURIComponent(password)}@your.proxy.here:8080`

@ luker2素晴らしい、あなたがそれを

このページは役に立ちましたか?
0 / 5 - 0 評価