SeleniumGrid并行执行只在dockerchrome节点上运行少数测试用例



现在我有80个使用数据提供程序的测试方法(@test(,我正在运行我的测试用例及其近400个测试用例。当我以硒网格并行方式运行它时,它只运行了几个测试用例。有时40有时50随机运行这是我的基本类

public class BaseTest {
private static final String OS = System.getProperty("os.name").toLowerCase();
public static boolean IS_WINDOWS = (OS.indexOf("win") >= 0);
public WebDriver driver;
String report = null;
public WebDriver getDriver() {
return driver;
}
@BeforeClass(alwaysRun = true)
public void classLevelSetup() throws InterruptedException {
//Did nothing
}
@BeforeMethod(alwaysRun = true)
public void methodLevelSetup() throws ParseException, MalformedURLException {
Log.info("Tests are starting!");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--disable-gpu");
chromeOptions.addArguments("--disable-extensions");
chromeOptions.addArguments("disable-infobars");
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("ignore-certificate-errors");
chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);
chromeOptions.addArguments("--start-maximized");
driver=new RemoteWebDriver(new 
URL("http://localhost:4444/wd/hub"),chromeOptions);

// Added Browser
}
@AfterMethod(alwaysRun = true)
public void AfterMethod(ITestResult result, ITestContext ctx)
{
getTest().fail(result.getThrowable());

driver.quit();
}
@AfterClass(alwaysRun = true)
public void teardown() {
//Did nothing
}

这是我的测试课

public class DashboardTest extends BaseTest {
@DataProvider(name = "CreateProperty")
public Object[][] getData() {
Object[][] data = SiteConfig.CreateProperty;
return data;
}
@Test(priority = 0, alwaysRun = true, dataProvider = "CreateProperty", description = "Add new property from Management > Properties")
public void Add_new_Property_from_management_Properties(String url, String username, String password, Method method, ITestContext ctx) throws Exception {
SignupPage sp = new SignupPage(driver);
sp.Open_login_Page(url);

}

}

这是我的testng.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<test name="CultBooking">
<classes>
<class name="tests.RoomTypeTest"></class>
<class name="tests.RoomTypeTest_1"></class>
<class name="tests.RoomTypeTest_2"></class>
<class name="tests.RoomTypeTest_3"></class>
<class name="tests.RoomValidatyApiResponseTest"></class>
<class name="tests.MealPlanTest"></class>
<class name="tests.MealPlanTest_1"></class>
<class name="tests.MasterdataTest"></class>
<class name="tests.DescriptionsTest"></class>
<class name="tests.SignupTest"></class>
<class name="tests.Reservation_processTest"></class>
<class name="tests.SignInTest"></class>
<class name="tests.DashboardTest"></class>
<class name="tests.ForgotPasswordTest"></class>
</classes>
</test>
**我在詹金斯管理所有的事情,这是我有时会遇到的错误**
Command: [54f8c566912260f004c50d969fb3fbb8, screenshot {}]
Capabilities {acceptInsecureCerts: false, browserName: chrome,
browserVersion: 96.0.4664.45, chrome: {chromedriverVersion:
96.0.4664.45 (76e4c1bb2ab46..., userDataDir: /tmp/.com.google.Chrome.DIPhAl}, goog:chromeOptions: {debuggerAddress:
localhost:36179}, javascriptEnabled: true, networkConnectionEnabled:
false, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX,
proxy: Proxy(), se:cdp: ws://172.19.0.4:4444/sessio..., se:cdpVersion:
96.0.4664.45, se:vnc: ws://172.19.0.4:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.19.0.4:7900, setWindowRect: true,
strictFileInteractability: false, timeouts: {implicit: 0, pageLoad:
300000, script: 30000}, unhandledPromptBehavior: dismiss and notify,
webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true,
webauthn:virtualAuthenticators: true} Session ID:
54f8c566912260f004c50d969fb3fbb8   at
jdk.internal.reflect.GeneratedConstructorAccessor27.newInstance(Unknown
Source)    at
java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at
java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
at
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
at
org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
at
org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
at
org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:50)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:559)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:614)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:618)
at
org.openqa.selenium.remote.RemoteWebDriver.getScreenshotAs(RemoteWebDriver.java:349)
at
utils.listeners.TestListener.saveScreenshotPNG(TestListener.java:39)
at utils.listeners.TestListener.onTestFailure(TestListener.java:78)
at
org.testng.internal.TestListenerHelper.runTestListeners(TestListenerHelper.java:96)
at
org.testng.internal.TestInvoker.runTestResultListener(TestInvoker.java:219)
at
org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:834)
at
org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146)
at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
at
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128)
at
java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at
java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)

有人能帮我解决这个问题吗

如果测试用例总数与预期不匹配,可能是因为某些testNG生命周期代码中出现异常。

首先,我说的是听众。

我在堆栈中看到utils.listeners.TestListener

saveScreenshotPNG会产生一些异常。

确保它的所有方法都不会抛出任何异常。环绕try-catch中的所有代码,因为TestNG无法准确处理侦听器中的异常。

另一个问题是,为什么有时saveScreenshotPNG中会发生异常。但无论如何,请先尝试使utils.listeners.TestListener成为故障安全型。

相关内容

  • 没有找到相关文章

最新更新