セレンとtestNGを使用してEclipseでJavaファイルを実行しようとしています。パッケージ名を (デフォルト パッケージ) から「コンテンツ」に変更しました。テストケースを実行すると、be below エラーがスローされて終了します。
org.testng.TestNGException:
Cannot instantiate class content.AddContent
クラスはこちら
public class AddContent {
private WebDriver driver;
String parentWindow = driver.getWindowHandle().toString();
//private String baseUrl;
//private StringBuffer verificationErrors = new StringBuffer();
@BeforeMethod
public void setUp(ITestContext context) throws Exception {
// String baseUrl = context.getCurrentXmlTest().getParameter("baseUrl");
driver = new FirefoxDriver();
//baseUrl = "http://mavrick.fhru.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@DataProvider
public Object[][] getData(){
Object[][] data = new Object[1][4];
data[0][0] = "http://mavrick.fhru.com";
data[0][1] = "superuser";
data[0][2] = "Ring123";
return data;
}
@Test (dataProvider="getData")
public void testAddContent(String baseUrl, String username, String password) throws Exception {
System.out.println("Going to the URL "+baseUrl);
driver.get(baseUrl);
Thread.sleep(500);
System.out.println("Checking for title...");
String rtitle = driver.getTitle();
String etitle = "Digital Servers";
try{
Assert.assertEquals(rtitle, etitle);
}catch(Throwable t){
System.out.println(" ERROR FOUND IN DS TITLE!! DS Login Page Title does not match");
System.out.println("Found "+rtitle+". Expected "+etitle);
System.out.println("The testcase will continue and will not be marked as failed.");
}
System.out.println("Maximizing the browser...");
driver.manage().window().maximize();
System.out.println("Entering "+username+" as Username...");
driver.findElement(By.id("username")).clear();
driver.findElement(By.id("username")).sendKeys(username);
System.out.println("Entering "+password+" as Password...");
driver.findElement(By.id("password")).clear();
driver.findElement(By.id("password")).sendKeys(password);
System.out.println("Clicking Sign in...");
driver.findElement(By.id("button")).click();
driver.findElement(By.id("contentImage")).click();
driver.findElement(By.id("bas")).click();
driver.switchTo().window("aapop");
driver.findElement(By.id("notselected")).click();
driver.findElement(By.id("url")).clear();
driver.findElement(By.id("url")).sendKeys("http://1.1.1.1/srsdsd/assests/ts1/gaming/");
driver.findElement(By.id("masks")).clear();
driver.findElement(By.id("masks")).sendKeys("*.mpeg");
//driver.findElement(By.className("ds_select_box")).click();
driver.findElement(By.xpath("//form[@id='subForm']/table/tbody/tr/td[2]/div/div/div")).click();
driver.findElement(By.xpath("//html/body/div/div[2]/div/div/div[2]/div/div/div[2]/form/table/tbody/tr/td[2]/div/div/ul/li[8]")).click();
//driver.findElement(By.tagName("Select")).click();
driver.findElement(By.xpath("//form[@id='subForm']/p[6]/div/div")).click();
driver.findElement(By.xpath("//html/body/div/div[2]/div/div/div[2]/div/div/div[2]/form/p[6]/div/ul/div/div/li[4]")).click();
//driver.findElement(By.xpath("//ul[@id='ul61']/li[8]")).click();
//driver.findElement(By.xpath("//ul[@id='ul87']/div/div/li[5]")).click();
//driver.findElement(By.id("ext-gen27")).click();
driver.findElement(By.xpath("//span[text() = 'Music']")).click();
driver.findElement(By.cssSelector("b")).click();
//driver.findElement(By.id("ext-gen46")).click();
driver.findElement(By.xpath("//tr/td[2]/em/button")).click();
driver.switchTo().window(parentWindow);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
driver.findElement(By.id("ext-gen205")).click();
System.out.println("Completed adding all the Channels. Now will Signout from DS");
driver.findElement(By.linkText("Sign Out")).click();
Thread.sleep(200);
System.out.println("Closing the browser and finishing the testcase.");
System.out.println("========================================================================");
}
@AfterMethod
public void tearDown() throws Exception {
driver.quit();
//String verificationErrorString = verificationErrors.toString();
//if (!"".equals(verificationErrorString)) {
// fail(verificationErrorString);
//}
}
}
助けてください。パッケージ名を変更するための手順はありますか?