【问题标题】:Response message: org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of:响应消息:org.apache.jorphan.util.JMeterException:调用 bsh 方法时出错:eval 源文件:内联评估:
【发布时间】:2017-07-26 07:29:49
【问题描述】:

当我将 selenium-server-standalone-2.53.0 替换为 %Jmeter%lib 文件夹中的 selenium-server-standalone-3.1.0 时,我收到此错误:

响应消息:org.apache.jorphan.util.JMeterException:调用 bsh 方法时出错:eval 源文件:内联评估:``import java.io.File;导入 java.io.FileReader;导入 java.io.FileWriter;重要。 . . ''

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;

import au.com.bytecode.opencsv.CSVReader;
import au.com.bytecode.opencsESRv.CSVWriter;

Boolean result=true;
public WebDriver driver;
try
{
     System.setProperty("webdriver.chrome.driver","Projects\\chromedriver.exe");
     driver=new ChromeDriver();

     driver.manage().window().maximize();
    driver.get("https://something.com/registration/");
     WebDriverWait wait = new WebDriverWait(driver, 20000);

     String uname= bsh.args[0];
     String pass= bsh.args[1];

      // Logged In 
     driver.findElement(By.xpath("//*[contains(@id,'menu-item')]//*[text()='Log In']")).click();
     driver.findElement(By.id("username")).sendKeys(new String[] {uname});
     driver.findElement(By.id("password")).sendKeys(new String[] {pass});
     driver.findElement(By.xpath("//*[@id='woocommerce-login-nonce']/following-sibling::*[@name='login']")).click();

     // Logged Out
     driver.findElement(By.xpath("//*[@id='masthead']//*[text()='Sign out']")).click();
}
catch (Exception ex) 
{
    ex.printStackTrace();
    IsSuccess = false;
    ResponseCode = "500";
    ResponseMessage = ex.getMessage();
    log.error(ex.getMessage());
    System.err.println(ex.getMessage());
} 
catch (Throwable thex) 
{
    System.err.println(thex.getMessage());
}
finally 
{
    driver.quit();
}
IsSuccess=result;
return result;

代码是用 Jmeter 中的 Beanshell Sampler 编写的。

【问题讨论】:

    标签: java selenium jmeter beanshell


    【解决方案1】:
    1. 只替换一个 Selenium 库是不够的,还需要升级其他依赖项

    2. 为了看到“正常”的堆栈跟踪,修改你的 catch 块看起来像:

      catch (Exception ex) {
          log.error("Something went wrong", ex);
      }
      
    3. 考虑切换到JSR223 SamplerGroovy language,因为Groovy 更符合Java 并且具有更好的性能。有关更详细的说明,请参阅Apache Groovy - Why and How You Should Use It

    【讨论】:

    • 更换单个 Selenium-Server-Standalone jar 就足够了,你只需要安装干净或新的 Jmeter。谢谢你帮助我.....
    猜你喜欢
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多