我知道这是最常见的问题,并得到了许多解决方案,并且有各种概率出现这个问题。我已经尝试了以下所有可能性,但仍然没有运气。
我知道这会有点冗长,但想根据以前的经验提供详细信息。
首先要考虑的 2 个重要事项:(我的测试套件包含超过 1K 的测试用例)
这在本地机器上运行良好,与远程抛出此问题的相同设置和代码相同
如果我运行低于 100 个测试用例,即使在远程机器上也能完美生成,但如果高于此,则会导致总测试运行:0,失败:0,跳过:0(因此范围报告也不会生成,但是所有测试用例都完美执行)
尝试的可能性:
检查所有方法的@Test注释
给定Void的所有 @Test 方法的返回类型
仅导入Testng 罐子和包(不是 Junit)
所有方法都只有公共访问权限(非私有)
TestNg在 Eclipse 中正确配置
完全刷卡并再次安装(也完成了许多重新启动:()
在构建路径中正确配置了所有必需的 jar
配置:
- 硒 - 3.7.1
- 测试NG - 6.13
- 蚂蚁 - 10.0.2
- 范围报告 - 2.4.1
- Eclipse 霓虹灯 4.6.3
注意:以上所有配置在本地和远程都相同,除了操作系统本地-win -7 和 10,远程机器-2012 服务器
我可以在没有看到代码的情况下理解,我们无法分析出了什么问题,但我不确定它是否会有所帮助,因为它在本地机器上工作但共享所需的代码
示例测试用例:
import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.rmi.UnexpectedException;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Random;
import java.util.Set;
import org.openqa.selenium.By;
import org.openqa.selenium.InvalidElementStateException;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;
import com.pps.atm.pom.ccl.*;
import com.pps.atm.pom.core_framework_components.*;
import com.pps.atm.pom.dataproviders.*;
import com.pps.atm.pom.dataproviders.URL_Setup.settingUrls;
import com.pps.atm.pom.pages.admin.*;
import com.pps.atm.pom.pages.frontend.*;
import com.relevantcodes.extentreports.LogStatus;
public class MyDev_Area_Local extends Local_DriverManager {
@Test
public void CK_DSK_LG_PopularToday_Newest_CTA_ActivateRewards_EUSignIn_SignInWithFB_Popup_Verification(
Method method) throws InterruptedException, AWTException {
ExtentTestManager.getTest().setDescription(
"Menu Popular today -> Automation Specific Store Category-> Newest tab, activate rewards existing user sign in sign in with FB popup verification..");
ExtentTestManager.getTest().log(LogStatus.INFO, "Test case : " + method.getName()
+ " - Execution Started With Thread ID : " + Thread.currentThread().getId());
System.out.println("Test case : " + method.getName() + " - Execution Started With Thread ID : "
+ Thread.currentThread().getId());
// Respective pages object creation
objHomePage = new HomePage(objDriver);
objMenuItems = new MenuItems(objDriver);
objVIP = new Voucher_Intermediate_Page(objDriver);
objComCTA = new Common_CTA_Buttons(objDriver);
objSUPLinkPage = new SignIn_Joinfree_Popup(objDriver);
objStoreCategoryPage = new StoreCategoryPage(objDriver)
测试 XML 文件:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite
name="PPS- Test Automation Framework for Desktop website - Local Execution"
parallel="tests" thread-count="1">
<listeners>
<listener class-name="com.pps.atm.pom.core_framework_components.TestListener" />
</listeners>
<test name="Execution on Firefox" parallel="methods" thread-count="1">
<parameter name="browser" value="firefox" />
<parameter name="platform" value="WINDOWS" />
<classes>
<class name="com.pps.atm.pom.devarea.MyDev_Area_Local" />
</classes>
</test>
</suite>
结果 :
[testng] [Parent 4896, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUserexecution completed with Thread ID : 10
[testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser - execution successfully completed :) ..!
[testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
[testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
[testng] 1520507985755 geckodriver INFO geckodriver 0.19.1
[testng] 1520507985799 geckodriver INFO Listening on 127.0.0.1:19279
[testng] 1520507986370 mozrunner::runner INFO Running command: "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe" "-marionette" "-profile" "C:\\Users\\ADMINI~1\\AppData\\Local\\Temp\\2\\rust_mozprofile.pxDUcwVEb9zl"
[testng] 1520507989413 Marionette INFO Enabled via --marionette
[testng] [Parent 3220, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[testng] 1520508003543 Marionette INFO Listening on port 57333
[testng] 1520508004282 Marionette WARN TLS certificate errors will be ignored for this session
[testng] Mar 08, 2018 11:20:05 AM org.openqa.selenium.remote.ProtocolHandshake createSession
[testng] INFO: Detected dialect: W3C
[testng] Test execution started on browser : firefox With Thread ID : 10
[testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP - execution started ..!
[testng] Test case : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP - Execution Started With Thread ID : 10
[testng] JavaScript error: https://dev6ck.iamsavings.co.uk//themes/ck-storepage-v2/js/plugins.min.1519992761.js, line 22: SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data
[testng] R Value as 1157784
[testng] Count tab 2
[testng] SignIn bonus as : 0.0
[testng] Referal bonus as : 0.0
[testng] UserReferral_Bonus_Value as : 0.0
[testng] Count tab 2
[testng] Testcase : CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP - execution Failed :( - please look into this ..!
[testng] [Parent 3220, Gecko_IOThread] WARNING: pipe error: 109: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 346
[testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
[testng] [GFX1-]: Receive IPC close with reason=AbnormalShutdown
[testng] [Child 1728, Chrome_ChildThread] WARNING: pipe error: 232: file z:/build/build/src/ipc/chromium/src/chrome/common/ipc_channel_win.cc, line 513
[testng] We are on - onFinish method : Execution on Firefox and finishing the testsuite execution ..!
[testng] ===============================================
[testng] PPS- Test Automation Framework for Desktop website - Local Execution
[testng] Total tests run: 0, Failures: 0, Skips: 0
[testng] ===============================================
[testng] The tests failed.
BUILD SUCCESSFUL
Total time: 286 minutes 2 seconds*
测试用例样本:
@Test
public void CK_DSK_WithoutReferal_SignUpBonus_As_Zero_And_ReferalBonusValue_As_Zero_UserReferralValue_AS_Zero_Setup_Verification_For_NewUser_From_JFPopUP(
Method method) throws InterruptedException, AWTException {
ExtentTestManager.getTest().setDescription(
"Navigating to Admins for Settings -> Parnter settings -> Setting Signup value as Zero & referal bonus value as Zero and verifying from the front end..");
ExtentTestManager.getTest().log(LogStatus.INFO, "Test case : " + method.getName()
+ " - Execution Started With Thread ID : " + Thread.currentThread().getId());
System.out.println("Test case : " + method.getName() + " - Execution Started With Thread ID : "
+ Thread.currentThread().getId());
objSoftAssertion = new SoftAssert();
objJF_PopUpPage = new JoinFreePage(objDriver);
objHomePage = new HomePage(objDriver);
objMyAccounts = new MyAccounts_Page(objDriver);
objAdminCoreFunc = new Admin_Core_Functions(objDriver);
objAdminLoginPage = new Admin_Login_Page(objDriver);
objPartner_Settings = new Settings_Partner_Settings(objDriver);
objSUPLinkPage = new SignIn_Joinfree_Popup(objDriver);
objUsersPage = new Users_Users_Page(objDriver);
objReferEarnPage = new Refer_Earn_Page(objDriver);
objAdmin_Search_Page = new Admin_Search_Page(objDriver);
objComCon = new Common_Controls(objDriver);
objComCTA = new Common_CTA_Buttons(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO, "Navigating to home page and Joining In ...");
objHomePage.navigateURL(objDriver);
objHomePage.signinPopup_Header_LinkClick(objDriver);
objSUPLinkPage.linkSignUp_Click(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO, "Navigating to get captcha page and returns captcha code...");
String strCaptchaValue = objSUPLinkPage.joinFreePopUp_Captch_Generation(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Return back to Join free page and entering all join free page field values ...");
String strNewJoin_UserEmail_1 = objJF_PopUpPage.joinFreePage_FeildValues_Entering_forUserName(objDriver,
strCaptchaValue);
String strNewJoin_Password_1 = testdata.get(1).get("strPassword").trim();
String strNewJoin_UserName_1 = testdata.get(1).get("strFirstName").trim();
objHomePage.userLoggedIn_Verification(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO, "Navigating to ReferFriend & fetching referral link ...");
objHomePage.dropdown_MYAccounts_Click(objDriver);
objMyAccounts.topMenu_ReferFriend_Navigation(objDriver);
String strNewJoin_Referal_Link = objReferEarnPage.fetch_Referal_Link(objDriver);
String[] strSplitValue = strNewJoin_Referal_Link.split("/r=");
String strNewJoin_Referal_Value = strSplitValue[1];
System.out.println("R Value as " + strNewJoin_Referal_Value);
objSUPLinkPage.logOut_Verification(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Navigating to admin URls and navigating to admin home page...");
String strFurtherStatus_0 = CCL_Class.General.tabToggle_NavigateNewURL_Tab_count_2(objDriver,
(URL_Setup.settingUrls.admin_Url_Base).trim());
objAdminLoginPage.enter_Credentials_And_Homepage_Navigation(objDriver);
// Setting User Referal Bonus values in user sub tab @ User main tab
ExtentTestManager.getTest().log(LogStatus.INFO,
"Navigating to adminSettings -> user main tab -> User sub tab -> User referral bonus ..");
objAdminLoginPage.mainmenu_Users_Click(objDriver);
objUsersPage.subMenu_Users_Navigation(objDriver);
// Admin Search page
objAdmin_Search_Page.searchPage_select_SearchBy(objDriver, "User Email");
objAdmin_Search_Page.searchPage_Input_Keyword_UserTab(objDriver, strNewJoin_UserEmail_1);
objAdmin_Search_Page.button_Submit_Users_Tab_User(objDriver);
objUsersPage.editButton_ResultTable(objDriver, strNewJoin_Referal_Value);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Setting user referal bonus values in user edit page & saving the values ...");
float intUserReferral_Bonus_Value = (float) objUsersPage
.editPartnerDetails_input_User_Referral_Bonus_Value(objDriver, 0);
objUsersPage.button_Save_Click(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Navigating to adminSettings -> Parnter settings -> Setting Signup bonus values..");
objAdminLoginPage.mainmenu_Settings_Click(objDriver);
objPartner_Settings.subMenu_Partner_Settings_Navigation(objDriver);
objPartner_Settings.editPartnerDetails_Editbutton_Click(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Setting Signup & referal bonus values in Parnter settings edit page & saving the values ...");
float intSignUp_Bonus_Value = (float) objPartner_Settings.editPartnerDetails_input_SignUp_Bonus_Value(objDriver,
0);
float intReferal_Bonus_Value = (float) objPartner_Settings
.editPartnerDetails_input_Referal_Bonus_Value(objDriver, 0);
objPartner_Settings.button_Save_Click(objDriver);
// will be removed
System.out.println("SignIn bonus as : " + intSignUp_Bonus_Value);
System.out.println("Referal bonus as : " + intReferal_Bonus_Value);
System.out.println("UserReferral_Bonus_Value as : " + intUserReferral_Bonus_Value);
ExtentTestManager.getTest().log(LogStatus.INFO, "Opening new tab and navigating to join free page to join...");
String strFurtherStatus = CCL_Class.General.tabToggle_NavigateNewURL_Tab_count_2(objDriver,
(URL_Setup.settingUrls.url_Home).trim());
objHomePage.signinPopup_Header_LinkClick(objDriver);
objSUPLinkPage.linkSignUp_Click(objDriver);
if (strFurtherStatus.contains("Success")) {
objJF_PopUpPage.joinFreePage_Navigated_Verification(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Opened new tab & Navigating to navigate join free page ...");
String strCaptchaValue_1 = objSUPLinkPage.joinFreePage_Captch_Generation_Tab_Count_3(objDriver);
ExtentTestManager.getTest().log(LogStatus.INFO,
"Return back to Join free page and entering all join free page field values ...");
objJF_PopUpPage.joinFreePage_FeildValues_Entering(objDriver, strCaptchaValue_1);
objHomePage.userLoggedIn_Verification(objDriver);
objHomePage.dropdown_MYAccounts_Click(objDriver);
objMyAccounts.topMenu_MyEarnings_Navigation(objDriver);
objMyAccounts.tab_MyEarnings_CBEarnings_Navigation(objDriver);
float intAvailableCB = objMyAccounts.cash_MyEarningsTab_AvailableCB(objDriver);
// Asserting the Cashback value with backend singup bonus data
if (intAvailableCB == intSignUp_Bonus_Value) {
ExtentTestManager.getTest().log(LogStatus.INFO,
"Successfully, Asserted live cashback & backend singup bonus data");
} else {
ExtentTestManager.getTest().log(LogStatus.FAIL,
"Assertion failed - for live cashback & backend singup bonus data");
}
System.out.println("SignIn bonus from frontend as : " + intAvailableCB);
} else {
ExtentTestManager.getTest().log(LogStatus.FAIL,
"not able to Open new tab and navigating to join free page to join...");
}
ExtentTestManager.getTest().log(LogStatus.INFO,
"Verified successfully that user as Joined with respective signup values entered in backend ...");
ExtentTestManager.getTest().log(LogStatus.INFO, "Testcase : " + method.getName()
+ "execution completed with Thread ID : " + Thread.currentThread().getId());
System.out.println("Testcase : " + method.getName() + "execution completed with Thread ID : "
+ Thread.currentThread().getId());
}