Skip to content

Parameter 'browser' is required by @Configuration on method setUp but has not been marked @Optional or defined #10

@meetparag81

Description

@meetparag81

Hello,
I am getting "Parameter 'browser' is required by @configuration on method setUp but has not been marked @optional or defined" message while running my test class
I have extended my base class to test class as well as I have added browser and url values in testng xml
Please refer code below

Base class
public class Baseclass_1
{
public static WebDriver driver;

@Parameters({"browser","url"})
@BeforeClass
public  void setUp(String browser,String url)
{
	if(browser.equalsIgnoreCase("firefox"))
	{
		System.setProperty("webdriver.gecko.driver","G:\\Javaprogramming\\Selenium\\Selenium Setup\\geckodriver.exe");
		driver=new ChromeDriver();
		
	}
	else if(browser.equalsIgnoreCase("chrome"))
	{
		
		
	}
	driver.get(url);
	driver.manage().window().maximize();
	
	driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
	
	
}

@AfterClass
public void tearDown()
{
	driver.quit();
		
}

===================================================================
Test class
public class FBTestnew extends Baseclass_1
{
WebDriver driver;

@Test	
public void LogintoFB()
{
	
	// Baseclass_1.setUp("firefox","https://www.facebook.com/");
	FBHome FB_Hpme =PageFactory.initElements(driver, FBHome.class);
	FB_Hpme.LogintoFB("username", "password");
	
}

}

Testng xml

	<classes>
		<class name="Com.Browser.Baseclass_1" />
	</classes>
</test>
But running a test class or testng xml The browser is not launched. Execuring RunAs TestNG class from test class following error seen

FAILED CONFIGURATION: @BeforeClass setUp
org.testng.TestNGException:
Parameter 'browser' is required by @configuration on method setUp but has not been marked @optional or defined

Where as on running testng by executing Run As TestNG Suite, following error seen.
[RemoteTestNG] detected TestNG version 6.8.0
[TestNG] Running:
G:\Javaprogramming\Maven2\testng.xml

Parameterization Test Suite
Total tests run: 0, Failures: 0, Skips: 0

Can Anyone help me?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions