현재 로컬 허브 1 개와 로컬 노드 2 개가있는 Selenium 그리드 설정이 있습니다. 허브는 테스트를 분산하여 병렬로 실행하고 노드에 배포 할 수 있습니다. 나는 테스트를 병행하고있다.Selenium Grid 병렬 테스트 실행
public class WebDriverSetup {
public static RemoteWebDriver getDriver() throws MalformedURLException{
String SELENIUM_HUB_URL = "http://localhost:4444/wd/hub";
ThreadLocal<RemoteWebDriver> remoteWebDriver = null;
DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
String proxy = System.getProperty("proxy");
if (proxy != null && !proxy.isEmpty()) {
System.out.println("Using proxy: " + proxy);
capabilities.setCapability(CapabilityType.PROXY, proxy);
}
try {
remoteWebDriver = new ThreadLocal<RemoteWebDriver>();
remoteWebDriver.set(new RemoteWebDriver(new URL(SELENIUM_HUB_URL),
capabilities));
} catch (MalformedURLException e) {
System.out.println("Tackle Issue with RemoteDriverSetup");
}
remoteWebDriver.get().manage().window()
.setSize(new Dimension(2880, 1524));
remoteWebDriver.get().manage().timeouts()
.pageLoadTimeout(10, TimeUnit.SECONDS);
remoteWebDriver.get().manage().timeouts()
.implicitlyWait(10, TimeUnit.SECONDS);
return remoteWebDriver.get();
}
}
내 테스트 스위트가 같은 것입니다 :
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Multiple Tests Suite" verbose="1" parallel="methods">
<test name="Test1">
<classes>
<class name="com.itesteverything.qa.Tests"></class>
</classes>
</test>
</suite>
시험이처럼 다음
는 RemoteWebDriver를 얻을 수있는 클래스 다음
public abstract class BaseTest
{
String testFolder;
String testName;
protected String envName;
protected Configuration config;
protected String host;
protected RemoteWebDriver driver;
protected String proxy;
protected SomeData someData;
protected SomeController someController;
public BaseTest() {
}
public BaseTest(String testFolder, String testName)
{
this.testFolder = testFolder;
this.testName = testName;
this.envName = System.getProperty("config");
this.proxy = System.getProperty("proxy");
config = this.envName;
}
@BeforeMethod
public void startTest(Method testMethod) {
LOG.info("Starting test: " + testMethod.getName());
try {
this.someData = new SomeData();
this.driver = WebDriverSetup.getDriver();
this.someController = new someController(this.driver, this.someData);
driver.navigate().to("https://" + this.host);
} catch (MalformedURLException e) {
System.out.println("MalformedURLException");
}
}
@AfterMethod
public void closeWindow() {
driver.close();
driver.quit();
}
}
기본 테스트입니다 :
이러한 테스트를 실행하는 동안, 나는 다음과 같은 오류
이 정보를 작성 수 : 버전 : '2.44.0'수정 '76d78cf323ce037c5f92db6c1bba601c2ac43ad8'시간 '2014년 10월 23일 13시 11분 40초' 을 드라이버 정보 : driver.version : RemoteWebDriver org.openqa.selenium.remote.SessionNotFoundException : 세션 ID가 null입니다. quit()를 호출 한 후 WebDriver를 사용하고 있습니까? 빌드 정보 : 버전 : '2.44.0', 수정본 : '76d78cf323ce037c5f92db6c1bba601c2ac43ad8', 시간 : '2014-10-23 13:11:40 ' 드라이버 정보 : driver.version : RemoteWebDriver at org.openqa.selenium.remote .HttpCommandExecutor.execute (HttpCommandExecutor.java:158) org.openqa.selenium.remote.RemoteWebDriver.findElement에서 org.openqa.selenium.remote.RemoteWebDriver.execute (RemoteWebDriver.java:572) (AT RemoteWebDriver.java:352) at org.openqa.selenium.remote.RemoteWebDriver.findElementById (RemoteWebDriver.java:393) at org.openqa.selenium.By $ ById.findElement (By.java:214) at org.openqa.selenium.remote .RemoteWebDriver.findElement (RemoteWebDriver.java:344) at org.openqa.selenium.support.pagefactory.DefaultElementLocator.fi com.sun.proxy에서 ndElement (DefaultElementLocator.java:59) . sun.reflect.NativeMethodAccessorImpl.invoke에서 sun.reflect.NativeMethodAccessorImpl.invoke0 (기본 방법) 에서 $ Proxy25.sendKeys (알 수없는 소스) (NativeMethodAccessorImpl.java 57) sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43에서 ) java.lang.reflect.Method.invoke (Method.java:606) org.testng.internal.MethodInvocationHelper.invokeMethod에서 (MethodInvocationHelper에서 .java : 80) at org.testng.internal.Invoker.invokeMethod (Invoker.java:673) at org.testng.internal.Invoker.invokeTestMethod (Invoker.java:842) at org.testng.internal.Invoker .invokeTestMethods (Invoker.java:1166) at org .testng.internal.TestMethodWorker.invokeTestMethods (TestMethodWorker.java:125) (org). TestMethodWorker.java:109)) at java.util.concurrent.ThreadPoolExecutor $ Worker.run (ThreadPoolExecutor.java:615) java.lang.Thread.run (Thread.java:745) 테스트 실패 : test2 FAILED REASON : 세션 ID가 null입니다. . quit()를 호출 한 후 WebDriver를 사용하고 있습니까?
누구나 알고 있나요?
미리 감사드립니다.
테스트 클래스 자체에서 @BeforeMethod에 드라이버를 설정하려고했는데, 이는 someController 및 someData를 테스트에 설정해야 함을 의미합니다. 각 드라이버가 SomeData 및 SomeController의 자체 인스턴스를 가져야한다고 가정 할 때이 두 객체는 ThreadSafe 여야합니다. 죄송합니다.이 질문에만 관련되어 있으므로 다른 질문을 제기 할 수 없습니다. ThreadLocal 오브젝트를 작성한 다른 클래스 (ThreadSafeBaseTest라고 가정 해 봅시다)를 제안한 다음 ThreadSafeBaseTest 또는 이와 유사한 항목을 확장하는 각 TestClass에서 사용 하시겠습니까? –
startedFromTheBottom
그것은 데이터와 컨트롤러에 무엇이 있는지에 달려 있습니다. 각 테스트에 특유한 것들입니까? –
예, 각 테스트 클래스에는 이러한 개체를 사용하고 각 테스트에 새 값을 할당하는 설치 방법 (@BeforeMethod 사용)이 있습니다. ThreadLocal 접근에 대한 귀하의 제안은 무엇입니까? –
startedFromTheBottom