我需要点击此iframe视频
library(dplyr)
# original df
df <- data.frame(min = 1:60, val = rnorm(60))
# create a grouping variable and add to df
grp <- floor(df$min / 6)
df <- data.frame(grp, df)
# create new df at 6 min level
new.df <- df %>%
group_by(grp) %>%
summarise(new.val = sum(val))
切换到框架的代码
<div class="videoWrapper" style="" xpath="1">
<iframe width="854" height="480" src="xxxxxxx" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen=""></iframe></div>
我尝试了这些逻辑,
逻辑1:
driver.switchto().frame("videoWrapper");
逻辑2:
WebElement video = driver.findElement(By.xpath("//*[@id='player_uid_840828282_1']/div[4]/div[1]"));
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].play();", video);
但是它没有用,请把我弄清楚!
答案 0 :(得分:1)
尝试使用以下代码切换到所需的框架:
driver.switchto().frame(driver.findElement(By.xpath("//div[@class='videoWrapper']/iframe")));
还请注意,您不能将play()
应用于div
节点,而不能应用于video
节点(例如<video></video>
)
答案 1 :(得分:-1)
driver.switchTo().frame(driver.findElements(By.tagName("iframe")));