尝试找到带有一个字符串参数返回错误的构造函数:selenium.example1 .(java.lang.String)

时间:2021-11-22 09:01:31

When I run my simple selenium test in JMeter I get this error

当我在JMeter运行简单的selenium测试时,我得到了这个错误

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*)

The below code is my simple selenium code

下面的代码是我的简单的selenium代码

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());
}

}

}

For this I have even added a default constructor and a constructor with a parameter even then it didn't work out and with this constructor I am not getting any error but my test are failing both in eclipse and JMeter

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

2 个解决方案

#1


0  

This is a warning log level is WARN, but for your question it warns on missing Constructor of class Example1, such constructor with String parameter, it will look like:

这是一个警告日志级别是WARN,但是对于您的问题,它会警告类Example1的缺失构造函数,该类构造函数具有String参数,它将如下所示:

 public Example1(String parameter) {
  ...
  System.out.println("parameter : " + parameter);

}

#2


0  

I added System.setProperties for browser and removed the constructors it worked for me

我添加了系统。浏览器的setProperties并移除它为我工作的构造函数。

#1


0  

This is a warning log level is WARN, but for your question it warns on missing Constructor of class Example1, such constructor with String parameter, it will look like:

这是一个警告日志级别是WARN,但是对于您的问题,它会警告类Example1的缺失构造函数,该类构造函数具有String参数,它将如下所示:

 public Example1(String parameter) {
  ...
  System.out.println("parameter : " + parameter);

}

#2


0  

I added System.setProperties for browser and removed the constructors it worked for me

我添加了系统。浏览器的setProperties并移除它为我工作的构造函数。