如何点击此页面上视频的视频控件中的播放按钮? http://prolifiq.com/inside-prolifiq/tiles/invite/
以下是页面来源。我确实看到了javascript' playpause'控制,但我不确定如何点击它。
<div id="videoModal" class="reveal-modal expand open" style="display: block; opacity: 1; visibility: visible; top: 100px;">
<video id="wp_mep_1" width="709" height="540" preload="none" controls="controls" poster="http://prolifiq.com/wp-content/themes/prolifiq/img/bgr-video.png">
<source type="video/mp4" src="http://prolifiq.com/wp-content/themes/prolifiq/videos/Prolifiq-Invite.mp4"></source>
<source type="video/webm" src="http://prolifiq.com/wp-content/themes/prolifiq/videos/Prolifiq-Invite.webm"></source>
<object width="709" height="540" data="http://prolifiq.com/wp-content/plugins/media-element-html5-video-and-audio-player/mediaelement/flashmediaelement.swf" type="application/x-shockwave-flash">
</video>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#wp_mep_1').mediaelementplayer({
m:1
,features: ['playpause','current','progress','duration','volume','tracks','fullscreen']
});
});
</script>
<a class="close-reveal-modal">×</a>
</div>
我可以通过点击&#34; x&#34;来关闭视频。使用xpath在播放器的右上角按钮。
以下是我的代码:
import java.util.List;
import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.Select;
public class prolifictestscript {
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://prolifiq.com";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testProlifictestscript() throws Exception {
driver.get(baseUrl + "/");
driver.findElement(By.xpath(".//*[@id='menu-item-1905']/a")).click();//click menu
driver.findElement(By.linkText("Tiles")).click();//click sub menu
driver.findElement(By.xpath("html/body/section[1]/div[2]/ul/li[5]/a")).click();//click invite tile
List<WebElement> downloadHeader = driver.findElements(By.xpath("//h1[text() = 'Invite']"));//verify h1 invite exists
if(downloadHeader.size() > 0)
{
System.out.println("Found h1 header Invite");
}
driver.findElement(By.xpath("html/body/section[1]/div/a/img")).click();//click movie box
//driver.findElement(By.xpath(".//*[@id='videoModal']")).click();//.//*[@id='videoModal']//not working
Thread.sleep(49000);//wait 49 seconds for video to end
driver.findElement(By.xpath(".//*[@id='videoModal']/a")).click();//click x button
}
@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 boolean isAlertPresent() {
try {
driver.switchTo().alert();
return true;
} catch (NoAlertPresentException e) {
return false;
}
}
private String closeAlertAndGetItsText() {
try {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
if (acceptNextAlert) {
alert.accept();
} else {
alert.dismiss();
}
return alertText;
} finally {
acceptNextAlert = true;
}
}
}
答案 0 :(得分:0)
使用Javascript来做到这一点,它在Flash播放器上运行良好 这里有一些关于可用标签HTML Audio/Video DOM Reference
的信息