首页 > 解决方案 > 跳过视频时间滑块 Selenium

问题描述

我正在尝试使用硒快进视频一段时间。HTML 标记如下所示:

<span class="mejs-time-total mejs-time-slider" style="width: 895px;" aria-label="Time Slider" aria-valuemin="0" aria-valuemax="83.733333" aria-valuenow="4.22" aria-valuetext="00:04" role="slider" tabindex="0" aria-hidden="true">
    <span class="mejs-time-buffering" style="display: none;"></span>
    <span class="mejs-time-loaded" style="width: 269.633px;"></span>
    <span class="mejs-time-current" style="width: 45px;"></span>
    <span class="mejs-time-handle" style="left: 38px;"></span>
    <span class="mejs-time-float" style="display: none;">
        <span class="mejs-time-float-current">00:00</span>
        <span class="mejs-time-float-corner"></span>
    </span>
</span>
<span class="mejs-time-current" style="width: 45px;"></span>

试图操纵价值,但它不起作用。这是我的代码:

WebElement element = context.getDriver()
    .findElement(By.xpath("//*[@class='mejs-time-total mejs-time-slider']"));
JavascriptExecutor executor = (JavascriptExecutor) getContext().getDriver();
executor.executeScript("arguments[0].setAttribute('width', '240');", element);

标签: javascriptselenium-webdriver

解决方案


推荐阅读