WebDriver driver;
@BeforeMethod
public void setup() {
System.setProperty("webdriver.gecko.driver", "C:\\SOFTWARE\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
driver.get("http/www.google.com");
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.get("http/www.google.com")
Not getting up only in testng but working on java main method then it working fine
@BeforeMethod should be run.
If the same code works in the main method, but doesn't work in the TestNG @BeforeMethod, then most likely the @BeforeMethod wasn't executed.
You can try to set a breakpoint to any line of the setup() method and run your code in the debug mode to see if the method gets called.
Alternatively, you can add some logger or a simple System.out.println("") statement somewhere in the method.
If the @BeforeMethod didn't run, check the following things: