我需要自动化播放网络应用程序 http:\wherever.tv 的电视频道,以测试频道是成功播放还是播放失败。我有用于频道播放的Selenium IDE 脚本。如果频道无法播放,我该如何处理。Channel 使用jwplayer
.How 如何显示 JWPlayer 的 Channel 失败消息。
下面是播放频道的代码。
public class Untitled {
private WebDriver driver;
private String baseUrl;
private boolean acceptNextAlert = true;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "http://wherever.tv/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testUntitled() throws Exception {
driver.get(baseUrl + "/index2.jsf");
driver.findElement(By.linkText("SIGN IN")).click();
driver.findElement(By.id("login:txtUserName")).clear();
driver.findElement(By.id("login:txtUserName")).sendKeys("testm1");
driver.findElement(By.id("login:txtPassword")).clear();
driver.findElement(By.id("login:txtPassword")).sendKeys("111111");
driver.findElement(By.id("login:cmbSumbit")).click();
driver.findElement(By.xpath("(//img[@title='(On Air) Play - This channel will work on TV'])[7]")).click();
driver.findElement(By.xpath("(//img[@title='(On Air) Play - This channel will NOT work on TV'])[4]")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alert.getText();
} finally {
acceptNextAlert = true;
}
}
}