Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter 'browser' is required by BeforeTest on method SetPropertyandopenBrowser but has not been marked @Optional or defined #23

Closed
Ojasadi opened this issue Jan 16, 2021 · 2 comments

Comments

@Ojasadi
Copy link

Ojasadi commented Jan 16, 2021

I am trying to run same test cases in different browser. Can anybody help what is wrong in this

Error:
Parameter 'browser' is required by BeforeTest on method SetPropertyandopenBrowser but has not been marked @optional or defined

package mytestngpackage;

import org.testng.annotations.Test;
import org.testng.Assert;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Parameters;

public class MultipleBrowser {

WebDriver DR;
//String browser;

@BeforeTest
@parameters("browser")

public void SetPropertyandopenBrowser(String browser) {

if(browser.equalsIgnoreCase("Chrome")) {
	System.setProperty("webdriver.chrome.driver","C:\\Users\\14049\\Desktop\\Selenium\\chromedriver_win32\\chromedriver.exe");
	DR=new ChromeDriver();
}
else if(browser.equalsIgnoreCase("Edge")) {
	System.setProperty("webdriver.edge.driver", "C:\\Users\\14049\\Desktop\\Selenium\\edgedriver_win64\\msedgedriver.exe");
	DR=new EdgeDriver() ;
}	
DR.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

}

@test(priority = 1)
public void openurl() {
DR.get("https://mail.rediff.com/cgi-bin/login.cgi");
String Actual= DR.getTitle(); //to know the title of webpage
Assert.assertEquals(Actual,"Rediffmail");

}

@test(priority = 2,dependsOnMethods = "openurl")
public void enterusername() {
DR.findElement(By.name("login")).sendKeys("[email protected]");
}
@test(priority=3,dependsOnMethods = "enterusername")
public void enetrpassword() {
DR.findElement(By.id("password")).sendKeys("12345");
}

}

@shawnlobo96
Copy link

The issue seems to be similar to #10

@Ojasadi can you take a look at it?

@Ojasadi
Copy link
Author

Ojasadi commented Jan 18, 2021

Ya...got it...Issue Resolved. Thanks

@Ojasadi Ojasadi closed this as completed Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants