gpt4 book ai didi

java - Selenium 与 BrowserMob 代理

转载 作者:行者123 更新时间:2023-12-02 06:26:16 27 4
gpt4 key购买 nike

我开始在 Selenium 上编写一些测试,并认为如果我能够在登录我们的网站时获得性能指标,那就太好了。我遇到了 BrowserMob-Proxy。我首先从 Lightbody 的 github 页面复制前五行,并且已经收到错误消息:“ProxyServer 无法解析为类型”和“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>
...

这是我试图创建方法“开始”和“结束”的类(“开始”尚未完成,我还没有创建“结束”...)。通过调用“start”,BrowserMob 应该开始测量性能,到“end”时,它应该停止测量...

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;

}

}

最佳答案

您的问题出在版本行上。看起来您是直接从 browsermob github 页面复制并粘贴的。相反,该行应该如下所示。

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

删除 LATEST_VERSION 和其他语法。

关于java - Selenium 与 BrowserMob 代理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20501095/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com