1

I am trying this cross-browser testing using Selenium.

CrossBrowser.java:

package automationFramewok;

import java.net.MalformedURLException;

import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.opera.OperaDriver;

import org.openqa.selenium.remote.DesiredCapabilities;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

import com.beust.jcommander.Parameters;

// I am getting the following error on the next line
//
//   "The attribute value is undefined for the annotation type Parameters"
//
@Parameters({"browser"})

public class CrossBrowser {

    @SuppressWarnings("deprecation")
    @BeforeTest

    public void setUp(String browser) throws MalformedURLException {

    if (browser.equalsIgnoreCase("Firefox")) {
       System.out.println("Running Firefox");
       System.setProperty("webdriver.gecko.driver","E:\\\\Selenium-required files\\geckodriver\\geckodriver.exe");
       FirefoxDriver driver = new FirefoxDriver();
    } else if (browser.equalsIgnoreCase("chrome")) {
       System.out.println("Running Chrome");
    System.setProperty("webdriver.chrome.driver", "E:\\\\\\\\Selenium-required files\\\\chromedriver\\\\chromedriver.exe");
       ChromeDriver driver = new ChromeDriver();
    } else if (browser.equalsIgnoreCase("opera")) {
       System.out.println("Running Opera");
    // driver = new OperaDriver();       --Use this if the location is set properly--
       DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("opera.binary", "C://Program Files (x86)//Opera//opera.exe");
       capabilities.setCapability("opera.log.level", "CONFIG");
       System.setProperty("webdriver.opera.driver", "E:\\\\\\\\Selenium-required files\\\\operadriver\\\\operadriver.exe");
       OperaDriver driver = new OperaDriver(capabilities);
    }
    }
}

I am receiving the following error message:

The attribute value is undefined for the annotation type Parameters

How can I resolve this?

1

2 Answers 2

2

Check out your list of import statements. I think you want

import org.testng.annotations.Parameters;

and not

import com.beust.jcommander.Parameters;
Sign up to request clarification or add additional context in comments.

Comments

-1

The same issue I was facing and problem was with import statement. I was using the following import statement.

import org.junit.runners.Parameterized.Parameters;

Replaced with the following import statement and issue got resolved.

import org.testng.annotations.Parameters;

2 Comments

How is this different from the other answer?
Concept is same, but the annotations that I was using earlier was different and was causing the same issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.