저는 어디서나 찾고 있었고 Source 연구소에서 스크립트를 실행하고 HAR 파일을 추출하기 위해 프록시를 올바르게 설정하는 방법에 대한 좋은 문서를 찾지 못했습니다. 임베디드 모드에서 BMP를 사용하고 있습니다. https://github.com/lightbody/browsermob-proxy#using-with-selenium, https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy. BMP를 통해 수동으로 스크립트를 설정하고 실행하는 방법에 대한 Source의 설명서는 https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy+with+an+Additional+Proxy+Setup이지만 독립형 모드를 통해서만 내장 모드로 설정하는 방법은 설명서에 나와 있지 않습니다. 여기 내 설정이다 :RemoteWebDriver/Sauce Labs/Sauce Connect로 BrowserMobProxy/Selenium 프록시를 올바르게 설정하는 방법은 무엇입니까?
내 PAC 파일을 백업 여기
package com.grainger.Framework;
import java.io.File;
import java.io.IOException;
import java.net.Inet4Address;
import java.net.UnknownHostException;
import org.apache.log4j.Logger;
import org.openqa.selenium.Proxy;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import com.grainger.Automation.Utilities;
import com.grainger.Build.BuildVariables;
import net.lightbody.bmp.BrowserMobProxy;
import net.lightbody.bmp.BrowserMobProxyServer;
import net.lightbody.bmp.client.ClientUtil;
import net.lightbody.bmp.core.har.Har;
import net.lightbody.bmp.proxy.CaptureType;
public class BrowserMobProxyImpl {
public static Logger log = Logger.getLogger(BrowserMobProxyImpl.class.getName());
private static BrowserMobProxy MOB_PROXY_SERVER;
private static Proxy SELENIUM_PROXY;
/**
* @author xsxg091
* @return
*/
public static void startBrowserMobProxyServer(){
// start the proxy
MOB_PROXY_SERVER = getProxyServer();
// get the Selenium proxy object
SELENIUM_PROXY = getSeleniumProxy(MOB_PROXY_SERVER);
}
/**
* @author xsxg091
* @return
*/
public static BrowserMobProxy getProxyServer() {
BrowserMobProxy proxy = new BrowserMobProxyServer();
proxy.setTrustAllServers(true);
proxy.start(9090);
return proxy;
}
/**
* @author xsxg091
* @param proxyServer
* @return
*/
public static Proxy getSeleniumProxy(BrowserMobProxy proxyServer) {
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxyServer);;
try {
String hostIp = Inet4Address.getLocalHost().getHostAddress();
seleniumProxy.setHttpProxy(hostIp + ":" + Integer.toString(9091));
seleniumProxy.setSslProxy(hostIp + ":" + Integer.toString(9091));
seleniumProxy.setAutodetect(false);
} catch (UnknownHostException e) {
log.error("Error initializing Selenium Proxy");
}
return seleniumProxy;
}
/**
* @author xsxg091
* @param tcName
* @param capabilities
*/
public static void setSeleniumProxy(DesiredCapabilities capabilities){
if(BuildVariables.amICapturingNetworkTraffic()){
capabilities.setCapability(CapabilityType.PROXY, SELENIUM_PROXY);
}
}
/**
* @author xsxg091
* @param tcName
* @param capabilities
*/
public static void stopBrowserMobProxyServer(){
MOB_PROXY_SERVER.stop();
}
/**
* @author xsxg091
* @return
*/
public static void getHarFile(String fileName) {
// enable more detailed HAR capture, if desired (see CaptureType for the complete list)
MOB_PROXY_SERVER.enableHarCaptureTypes(CaptureType.REQUEST_CONTENT, CaptureType.RESPONSE_CONTENT);
MOB_PROXY_SERVER.newHar(fileName);
try {
// get the HAR data
Har pageHarFile = MOB_PROXY_SERVER.getHar();
File harFile = new File(Utilities.getWorkSpace()+"//"+fileName+".har");
pageHarFile.writeTo(harFile);
} catch (IOException e) {
log.error("Unable to store Har File");
}
}
}
function FindProxyForURL(url, host) {
if (shExpMatch(host, "*.miso.saucelabs.com") ||
shExpMatch(host, "saucelabs.com")) {
// KGP and REST connections. Another proxy can also be specified.
return "DIRECT";
}
// Test HTTP traffic, route it through the local BrowserMob proxy.
return "PROXY localhost:9091";
}
BMP 세트 내 소스 터널 킥오프하는 데 사용하는 명령입니다
bin/sc -u ****** -k *********** -i Tunnel_Testing -v --pac file:///<path-to-pac-file>/BrowserMobProxy/browserMob.js
I lsof를 실행하면 9090 포트를 적극적으로 수신 대기 할 수 있지만 임베디드 모드에서는 9091이 표시되지 않습니다. 그러나 독립 실행 형 모드로 실행하면 포트와 모든 것이 소스 실험실에서 완벽하게 작동한다는 것을 알 수 있습니다. 내가 무슨 일을
을하고있는 중이 야 : 내가 포함 된 모드로 실행할 때 나는이 보여? 어떤 도움이라도 대단히 감사하겠습니다. 불명확 한 것이 있으면 알려 주시기 바랍니다.
미리 감사드립니다.