CSVデータセットの設定を使用して、複数のユーザーでテストアプリケーションにログインするためにJunit Requestサンプラーを使用しようとしました。例:スレッド数を2に設定し、2つのユーザーログインの詳細を.csvファイルに設定してテストを実行します。その結果、2つのFirefoxブラウザと1つのブラウザが正常にログオンし、他のブラウザはログインページのユーザー名とパスワードフィールドにユーザー名とパスワードを取得しませんでした。これは私のセレンのスクリプトコードです。誰でもこの問題の理由を提案できますか?JUnitサンプラーがCSVデータセットで正常に動作しない複数のスレッド用の構成Jmeter
import org.apache.jmeter.protocol.java.sampler.JUnitSampler;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class testClass {
static WebDriver driver;
JUnitSampler sampler = new JUnitSampler();
String userName = sampler.getThreadContext().getVariables().get("username");
String password = sampler.getThreadContext().getVariables().get("password");
String Empnamecsv = sampler.getThreadContext().getVariables().get("Empname");
@BeforeClass
public static void setUpBeforeClass() throws Exception
{
System.setProperty("webdriver.gecko.driver", "D:\\Automation\\Geckodriver\\V0.19.0\\geckodriver.exe");
driver = new FirefoxDriver();
}
@Test
public void loadHomePage() throws InterruptedException
{
driver.get("http://localhost/testWeb");
Thread.sleep(1000);
}
@Test
public void login() throws InterruptedException
{
driver.findElement(By.id("txtusername")).sendKeys(userName);
driver.findElement(By.id("txtpassword")).sendKeys(password);
driver.findElement(By.id("btnsubmit")).click();
Thread.sleep(1000);
String name = driver.findElement(By.xpath("/html/body/div[1]/div[2]/div[3]/span[1]/span[1]")).getText();
Assert.assertEquals(name,namecsv);
}
}
あなたはエラーの原因を教えてください。 –
2つのjunitリクエストサンプラーを使用しました。最初のjunitリクエストサンプラーでクラス名をtestClass、setUpBeforeClassメソッドをTest Methodとして設定します。 2番目のjunitリクエストサンプラーでは、クラス名をtestClassに設定し、ログインメソッドをテストメソッドとして設定し、スレッドグループを実行します。その結果、2つのFirefoxブラウザが開かれ、URLが正常に読み込まれました。しかし、1つのブラウザだけがアプリケーションの成功に完全にログオンし、他のブラウザはログインデータがユーザー名とパスワードフィールドに挿入されずにログインできません。それが問題です。 –