#Add Customer Test
package com.homzhub.testcases;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.homzhub.base.TestBase;
import com.homzhub.utilities.TestUtil;
public class AddCustomerTest extends TestBase {
@Test(dataProviderClass = TestUtil.class, dataProvider = "dp")
public void addCustomerTest(String firstName, String lastName, String postCode)
throws InterruptedException {
click("addCustBtn_CSS");
type("firstNametxtfield_CSS", firstName);
type("lastNametxtfield_XPATH", lastName);
type("postCodetxtfield_CSS", postCode);
click("addBtn_CSS");
Thread.sleep(2000);
/*
* Alert alert = wait.until(ExpectedConditions.alertIsPresent());
*
* Assert.assertTrue(alert.getText().contains(alerttext)); alert.accept();
*
* Thread.sleep(2000);
*/
}
/*
* @DataProvider(DataProvider.class) public Object [][] getData(){
*
* String sheetName = "AddCustomerTest"; int rows =
* excel.getRowCount(sheetName); int cols = excel.getColumnCount(sheetName);
*
* Object [][] data = new Object[rows-1][cols];
*
* for(int rowNum=2; rowNum<=rows; rowNum++) {
*
* for(int colNum=0; colNum<cols; colNum++) {
*
* data[rowNum-2][colNum] = excel.getCellData(sheetName, colNum, rowNum);
* System.out.println("Row and Column data printed successfully!!" + data); } }
*
* return data; }
*/
}
获取错误
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------< com.homzhub:DataDriverFramework >-------------------
[INFO] Building DataDriverFramework 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.testng:testng:jar:5.14.3 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.testng:testng:jar:5.14.4 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for org.testng:testng:jar:5.14.5 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[WARNING] The POM for com.beust:jcommander:jar:1.66 is missing, no dependency information available
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ DataDriverFramework ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ DataDriverFramework ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ DataDriverFramework ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ DataDriverFramework ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 10 source files to D:\rohit\eclipse-workspace\DataDriverFramework\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.18.1:test (default-test) @ DataDriverFramework ---
[INFO] Surefire report directory: D:\rohit\eclipse-workspace\DataDriverFramework\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 45591
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1563189899.905][WARNING]: This version of ChromeDriver has not been tested with Chrome version 75.
Jul 15, 2019 4:55:00 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Excel sheetname !- addCustomerTest
rows are :5
columns are :4
before Objetc class
after Objetc class
Excel sheetname !- openAccountTest
rows are :2
columns are :2
before Objetc class
after Objetc class
in row2
in col0
in col1
Tests run: 3, Failures: 2, Errors: 0, Skipped: 0, Time elapsed: 37.929 sec <<< FAILURE! - in TestSuite
addCustomerTest(com.homzhub.testcases.AddCustomerTest) Time elapsed: 7.139 sec <<< FAILURE!
org.testng.internal.reflect.MethodMatcherException:
Data provider mismatch
Method: addCustomerTest([Parameter{index=0, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=1, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=2, type=java.lang.String, declaredAnnotations=[]}])
Arguments: [(java.lang.String) sheetal,(java.lang.String) jadhao,(java.lang.String) 423948.0,(java.lang.String) Customer Added successfully!]
at org.testng.internal.reflect.DataProviderMethodMatcher.getConformingArguments(DataProviderMethodMatcher.java:45)
at org.testng.internal.Parameters.injectParameters(Parameters.java:796)
at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:983)
at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
at org.testng.TestRunner.privateRun(TestRunner.java:648)
at org.testng.TestRunner.run(TestRunner.java:505)
at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
at org.testng.SuiteRunner.run(SuiteRunner.java:364)
at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
at org.testng.TestNG.runSuites(TestNG.java:1049)
at org.testng.TestNG.run(TestNG.java:1017)
at org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:295)
at org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:84)
at org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:90)
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:203)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:155)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:103)
openAccountTest(com.homzhub.testcases.OpenAccountTest) Time elapsed: 20.33 sec <<< FAILURE!
org.openqa.selenium.NoSuchElementException: Cannot locate element with text: Rohit Barnwal
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'DESKTOP-B50U37U', ip: '10.1.112.64', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_211'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.Select.selectByVisibleText(Select.java:147)
at com.homzhub.base.TestBase.select(TestBase.java:158)
at com.homzhub.testcases.OpenAccountTest.openAccountTest(OpenAccountTest.java:18)
Results :
Failed tests:
AddCustomerTest.addCustomerTest » MethodMatcher
Data provider mismatch
Method...
OpenAccountTest.openAccountTest:18->TestBase.select:158 » NoSuchElement Cannot...
Tests run: 3, Failures: 2, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 43.673 s
[INFO] Finished at: 2019-07-15T16:55:33+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.18.1:test (default-test) on project DataDriverFramework: There are test failures.
[ERROR]
[ERROR] Please refer to D:\rohit\eclipse-workspace\DataDriverFramework\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException