2013-12-10 100 views
0

我開始在Selenium上編寫一些測試,並認爲如果能夠在登錄我們的網站時獲得性能指標,這將是一件好事。我遇到了BrowserMob-Proxy。我從Lightbody的github頁面複製了前五行開始,並且已經收到錯誤消息:「ProxyServer無法解析爲某種類型」和「代理無法解析爲某種類型」。Selenium with BrowserMob-Proxy

有人可以告訴我什麼仍然在這裏失蹤?

這裏的pom.xml中:

... 
</plugins> 
</build> 
<dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>4.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jboss.arquillian.junit</groupId> 
     <artifactId>arquillian-junit-container</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jboss.arquillian.extension</groupId> 
     <artifactId>arquillian-drone-impl</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <!-- 20131112 ab hier neu hinzugefügt von "https://docs.jboss.org/author/display/ARQ/Drone" --> 
    <dependency> 
     <groupId>org.jboss.arquillian.extension</groupId> 
     <artifactId>arquillian-drone-webdriver-depchain</artifactId> 
     <version>${version.org.jboss.arquillian.drone}</version> 
     <type>pom</type> 
     <scope>test</scope> 
    </dependency> 
    <!-- bis hier --> 
    <dependency> 
     <groupId>org.jboss.arquillian.extension</groupId> 
     <artifactId>arquillian-drone-selenium</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.jboss.arquillian.extension</groupId> 
     <artifactId>arquillian-drone-selenium-server</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-java</artifactId> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.seleniumhq.selenium</groupId> 
     <artifactId>selenium-server</artifactId> 
     <scope>test</scope> 
     <exclusions> 
      <exclusion> 
       <groupId>org.mortbay.jetty</groupId> 
       <artifactId>servlet-api-2.5</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-simple</artifactId> 
     <version>1.6.4</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>net.lightbody.bmp</groupId> 
     <artifactId>browsermob-proxy</artifactId> 
     <version>LATEST_VERSION (ex: 2.0-beta-9)</version> 
     <scope>test</scope> 
     <exclusions> 
      <exclusion> 
       <groupId>org.seleniumhq.selenium</groupId> 
       <artifactId>selenium-api</artifactId> 
      </exclusion> 
     </exclusions> 
    </dependency> 
</dependencies> 
<profiles> 
    <profile> 
     <id>arquillian-weld-ee-embedded</id> 
     <activation> 
      <activeByDefault>true</activeByDefault> 
     </activation> 
     <dependencies> 
      <dependency> 
       <groupId>org.jboss.spec</groupId> 
       <artifactId>jboss-javaee-6.0</artifactId> 
       <version>1.0.0.Final</version> 
       <type>pom</type> 
       <scope>provided</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.jboss.arquillian.container</groupId> 
       <artifactId>arquillian-weld-ee-embedded-1.1</artifactId> 
       <version>1.0.0.CR3</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.jboss.weld</groupId> 
       <artifactId>weld-core</artifactId> 
       <version>1.1.5.Final</version> 
       <scope>test</scope> 
      </dependency> 
      <dependency> 
       <groupId>org.slf4j</groupId> 
       <artifactId>slf4j-simple</artifactId> 
       <version>1.6.4</version> 
       <scope>test</scope> 
      </dependency> 
     </dependencies> 
    </profile> 
    <profile> 
     <id>arquillian-glassfish-embedded</id> 
     <dependencies> 
... 

這裏的地方我試圖使方法「開始」和「結束」類(「開始」還沒有完成,我的天堂」 t'結束'...)。通過調用'start',BrowserMob應該開始測量性能,'結束'它應該停止測量...

import org.openqa.selenium.WebDriver; 
import org.openqa.selenium.remote.DesiredCapabilities; 

public class Timer { 

public void start() { 

    // start the proxy 
    ProxyServer server = new ProxyServer(4444); 
    server.start(); 

    // get the Selenium proxy object 
    Proxy proxy = server.seleniumProxy(); 

    // configure it as a desired capability 
    DesiredCapabilities capabilities = new DesiredCapabilities(); 
    capabilities.setCapability(CapabilityType.PROXY, proxy); 

    // start the browser up 
    WebDriver driver; 

} 

} 

回答

2

你的問題在於版本行。它看起來像你從browsermob github頁面直接複製和粘貼。相反,線應該看起來像這樣。

<version>2.0-beta-9</version> 

刪除LATEST_VERSION和其他語法。

0

Try BrowserMobProxyServer server = new BrowserMobProxyServer(); 然後獲得它的正常代理。 是的,獲取最新版本。