尝试查找带有一个String参数的构造函数返回错误:selenium.examples.Example1。<init>(java.lang.String)

时间:2017-08-30 05:10:22

标签: selenium junit jmeter

当我在JMeter中运行我的简单硒测试时,我收到此错误

2017-08-30 10:24:28,887 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.assertions.BSFAssertion

   2017-08-30 10:24:29,567 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.extractor.BSFPostProcessor

   2017-08-30 10:24:29,627 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.modifiers.BSFPreProcessor

2017-08-30 10:24:29,677 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser

2017-08-30 10:24:29,677 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser

   2017-08-30 10:24:29,677 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser

   2017-08-30 10:24:29,677 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser

   2017-08-30 10:24:29,678 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser

    2017-08-30 10:24:29,678 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser

    2017-08-30 10:24:30,271 INFO o.a.j.e.KeyToolUtils: keytool found at 'keytool'

    2017-08-30 10:24:30,273 INFO o.a.j.p.h.p.ProxyControl: HTTP(S) Test Script Recorder SSL Proxy will use keys that support embedded 3rd party resources in file D:\apache-jmeter-3.2\bin\proxyserver.jks

    2017-08-30 10:24:30,586 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.protocol.java.sampler.BSFSampler

    2017-08-30 10:24:30,645 INFO o.a.j.s.FileServer: Default base='D:\apache-jmeter-3.2\bin'

    2017-08-30 10:24:30,763 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.protocol.mongodb.config.MongoSourceElement

    2017-08-30 10:24:30,763 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.protocol.mongodb.sampler.MongoScriptSampler

    2017-08-30 10:24:31,166 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.timers.BSFTimer

    2017-08-30 10:24:31,218 INFO o.a.j.g.u.MenuFactory: Skipping org.apache.jmeter.visualizers.BSFListener

    2017-08-30 10:24:31,471 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times

    2017-08-30 10:24:31,472 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to ISO-8859-1

    2017-08-30 10:24:31,472 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true

    2017-08-30 10:24:31,472 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000

    2017-08-30 10:24:53,357 INFO o.a.j.e.StandardJMeterEngine: Running the test!

    2017-08-30 10:24:53,357 INFO o.a.j.s.SampleEvent: List of sample_variables: []

    2017-08-30 10:24:53,357 INFO o.a.j.s.SampleEvent: List of sample_variables: []

    2017-08-30 10:24:53,363 INFO o.a.j.g.u.JMeterMenuBar: setRunning(true, *local*)

    2017-08-30 10:24:53,568 INFO o.a.j.e.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group

    2017-08-30 10:24:53,568 INFO o.a.j.e.StandardJMeterEngine: Starting 1 threads for group Thread Group.

    2017-08-30 10:24:53,569 INFO o.a.j.e.StandardJMeterEngine: Thread will continue on error

    2017-08-30 10:24:53,569 INFO o.a.j.t.ThreadGroup: Starting thread group... number=1 threads=1 ramp-up=1 perThread=1000.0 delayedStart=false

    2017-08-30 10:24:53,575 INFO o.a.j.t.ThreadGroup: Started thread group number 1

    2017-08-30 10:24:53,575 INFO o.a.j.e.StandardJMeterEngine: All thread groups have been started

    2017-08-30 10:24:53,577 INFO o.a.j.t.JMeterThread: Thread started: Thread Group 1-1

    2017-08-30 10:24:53,581 INFO o.a.j.p.j.s.JUnitSampler: Trying to find constructor with one String parameter returned error: selenium.examples.Example1.<init>(java.lang.String)

    2017-08-30 10:24:53,723 INFO o.a.j.t.JMeterThread: Thread is done: Thread Group 1-1

    2017-08-30 10:24:53,723 INFO o.a.j.t.JMeterThread: Thread finished: Thread Group 1-1

    2017-08-30 10:24:53,724 INFO o.a.j.e.StandardJMeterEngine: Notifying test listeners of end of test

    2017-08-30 10:24:53,725 INFO o.a.j.g.u.JMeterMenuBar: setRunning(false, *local*)

以下代码是我简单的硒代码

import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Example1 {

@Test
public void test() {
    WebDriver driver = new FirefoxDriver();
    driver.get("http://www.google.com");
    System.out.println("Title : " + driver.getTitle());
}

}

为此我甚至添加了一个默认构造函数和一个带参数的构造函数,即使它没有工作,使用这个构造函数我没有得到任何错误,但我的测试在eclipse和JMeter都失败

2 个答案:

答案 0 :(得分:0)

这是一个警告日志级别是WARN,但对于你的问题,它警告缺少类Example1的构造函数,这样的构造函数使用String参数,它将如下所示:

iris = mutate(iris, Species_mod = substr(Species, 1, nchar(as.character(Species)) - 
    ifelse(grepl('^vi', Species), 1, 2)))

答案 1 :(得分:0)

我为浏览器添加了System.setProperties并删除了它为我工作的构造函数