简体   繁体   English

跨浏览器测试脚本显示“注释类型参数的属性值未定义”错误

[英]“The attribute value is undefined for the annotation type Parameters” error is displayed for Cross-Browser Testing Script

I am trying this cross-browser testing using Selenium. 我正在尝试使用Selenium进行跨浏览器测试。

CrossBrowser.java : 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? 我该如何解决?

Check out your list of import statements. 查看您的导入语句列表。 I think you want 我想你要

import org.testng.annotations.Parameters;

and not 并不是

import com.beust.jcommander.Parameters;

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;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为“MediaType.APPLICATION_JSON”生成的注释类型的属性值未定义 - The attribute value is undefined for the annotation type Produces for “MediaType.APPLICATION_JSON” 跨浏览器cookie不一致? - Cross-browser cookie inconsistency? 如何在Cucumber for Java中执行标记驱动的跨浏览器测试? - How do I perform tag driven cross-browser testing in Cucumber for Java? 如何使用Java在多个浏览器中运行Selenium测试以进行跨浏览器测试? - How to run Selenium tests in multiple browsers for cross-browser testing using Java? 尝试使用TestNG执行跨浏览器测试脚本,但给出错误“失败的配置:@BeforeTest Browser(null)” - Trying to execute cross browser testing script using TestNG but giving error “FAILED CONFIGURATION: @BeforeTest Browser(null)” 对于注释类型Transactional,未定义属性readOnly - The attribute readOnly is undefined for the annotation type Transactional 注释类型Query的属性nativeQuery未定义 - The attribute nativeQuery is undefined for the annotation type Query 注释类型 SerializedName 的属性“alternate”未定义 - The attribute “alternate” is undefined for the annotation type SerializedName JAXB:注释类型XmlElement的属性名称未定义 - JAXB: The attribute name is undefined for the annotation type XmlElement 注释类型测试的预期属性未定义 - the attribute expected is undefined for the annotation type test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM