@After Erreur de configuration d'échec de méthode s'affiche lorsque je cours ce code.TestNG a échoué Confguration @AfterTest
package automationFramework;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import pageobjects.LoginPageObj;
public class TestCase_POF {
WebDriver driver;
LoginPageObj lpo;
@BeforeMethod
public void beforeMethod() {
System.setProperty("webdriver.chrome.driver", "h:\\chromedriver.exe");
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
options.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(options);
driver.get("https://slingshotinsights.com/");
}
@Test
public void test() {
lpo = PageFactory.initElements(driver, LoginPageObj.class);
lpo.LoginAction("johnmc", "k12345678");
System.out.println("User has been Logged-in Successfully");
}
@AfterMethod
public void afterMethod() {
driver.quit();
}
}
Ci-dessous est la sortie de la console Eclipse CONFIGURATION FAILED: @AfterMethod afterMethod java.lang.NullPointerException
S'il vous plaît Aidez-moi, merci – naqash
Pas très clair de votre question cependant. Mais il semble que le 'driver' est nul quand l'exécution a atteint' @ AfterMethod'. Est-ce tout ce code que vous avez? et le pilote dans le '@ BeforeMethod' est-il réglé correctement? – nullpointer
try @AfterSuite annotation tag à la place –