eclipse - Solution to NullPointerException in my TestNG test case -
I use code: I can not seem to know where the problem is? Then how to solve it < For one thing, do not use "exception throws" in the method declaration. Instead, a " Blue assurrant ". Keep in mind that you never want to throw a specific exception in a test math, because it will soon put you out of the test life cycle and will skip its @ later steps. An exception to be thrown into an @bean annotated method is probably a scrap ester Not the cause. Therefore, you want to fail the failed claims instead. Therefore, if you have an exception condition that sometimes occurs, do not swallow exception (throwing it) and use an indictment to handle it. For example: testng from external Excel sheet using multiple sets of entry code but what I wrote throws the code in it:
Failed on DataDriven.loginRetesting.f (loginRetesting.java31) on F JavaklangkNullPointerException on sun.reflect.NativeMethodAccessorImpl.invoke0 (Basic Law) sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:57) at sun.reflect.DellegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke (method.java:601) org.testng. org.testng.internal.Invoker on org.testng.internal.Invoker.invokeMethod (Invoker.java:714) on internal.MethodInvocationHelper.invokeMethod (methodInvocationHelper.java:84). org.testng.internal at org.testng.internal.TestMethodWorker.invokeTestMethods (TestMethodWorker.java:127) at invokeTestMethod (Invoker.java: 901) at org.testng.internal.Invoker.invokeTestMethods (Invoker.java:1231). on org.testng.TestRunner.privateRun (TestRunner.java:767) on TestMethodWorker.run (org.testng) on org.testng.TestRunner.run (TestRunner.java:617) (TestMethodWorker.java:111) Org.testng. Org.testng.SuiteRunner.runSequentially at (SuiteRunner.java:329) at org.testng.SuiteRunner.privateRun (SuiteRunner.java Month 19) on SuiteRunner.run .SuiteRunner.runTest (SuiteRunner.java:334) (Org.testng Org.testng.TestNG.runSuitesSequentially (TestNG.java:1224)) at org.testng.TestNG at (at SuiteRunnerWorker.java:.ro) on org.testng.SuiteRunnerWorker.run at (SuiteRunnerWorker.java:52) on SuiteRunnerWorker.RunSuite. .runSuites locally (testNG.java.1149) at org.testng.TestNG.run (testNG.java:1057) org.test On ng.remote.RemoteTestNG.run (remote Testanjikjawapro 11) (org.testng.remote.RemoteTestNG.main .testng.remote.RemoteTestNG.initAndRun organization) at (RemoteTestNG.java.15) < / pre>
@Test public void f () throws exception {FileInputStream fi = new FileInputSt team ( "e: \\ Workspace99 SeleniumAutomations \\ \\ \\ Testdata LoginData .xls "); Workbook w = workbook Jambookbook (fi); Sheet s = w.getSheet (0); (Int i = 1; i & lt; 8; i ++) {driver.findElement (By.id ("email")) sendKeys (s.getCell (0, i) .getContents ()); . Driver.findElement (By.id ("Passed")) SendKeys (s.getCell (1, i) .getContents ()); . Click on Driver.findElement (By.id ("u_0_1")) (); Thread.Sleep (1000); If (selenium.easelment performance ("id = universal label")) {//driver.findElement (BKSSSXL) (click on ".pdf"). Click (); Driver.findElement (By.id ("userNavigationLabel")). Click on Driver.findElement (By.cssSelector ("input.uiLinkButtonInput")); Thread.Sleep (1000);} Else {System. Out.println ("invalid crash"); driver.findElement (By.id ("email")) Clear ();. Driver.findElement (By.id ("passed")) Clear ();}}} < / Code>
try {} hold (NullPointerException e) {Assert.assertTrue ("Blah was an error.", False); }
Comments
Post a Comment