2017-12-02 23 views
0

私はこのクロスブラウザテストで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); 
    } 
    } 
} 

私は、次のエラーメッセージを受け取るのですか?

+2

こんにちはそして歓迎したいと思います!この記事で役に立つコードを書式設定するためのガイドがあります:https://stackoverflow.com/editing-help#code乾杯! –

答えて

0

インポートステートメントのリストを確認してください。私はあなたが

import org.testng.annotations.Parameters; 

なく

import com.beust.jcommander.Parameters; 
+0

ありがとうございます。それを解決した –

関連する問題