超全模态模型 × Harness 升级,升级解锁 ArkClaw,最新支持 DeepSeek-V4 系列与 GLM-5.1
你错误将普通DOM元素(#viewer、#toolbar、#downloads均为div类元素)当作执行了切换操作,<code>switchTo().frame()</code>仅对页面中的<iframe>标签生效,连续切换不存在的iframe会导致后续元素定位上下文完全错误。</p> <h2 id="可行操作步骤">可行操作步骤 <a class="header-anchor" href="#可行操作步骤" aria-hidden="true">#</a></h2> <ul> <li>第一步:确认页面中承载PDF查看器的真实iframe,先打印页面所有iframe的属性,确认正确的iframe选择器,不要直接把元素id当作iframe id盲目切换</li> <li>第二步:仅切换1次到目标iframe后直接定位按钮,新增显式等待避免元素未加载完成导致的点击失败</li> <li>第三步:操作完成后切回默认页面上下文,避免后续其他元素定位受影响</li> </ul> <h2 id="可运行java代码示例">可运行Java代码示例 <a class="header-anchor" href="#可运行java代码示例" aria-hidden="true">#</a></h2> <pre class="hljs"><code class="language-java volc-pre-code">import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import java.time.Duration; // 替换下方xpath为你实际页面中PDF查看器对应的真实iframe选择器 WebElement pdfIframe = driver.findElement(By.xpath("//iframe[contains(@id, 'viewer')]")); driver.switchTo().frame(pdfIframe); // 等待10秒直到下载按钮可点击 WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10)); WebElement downloadBtn = wait.until(ExpectedConditions.elementToBeClickable(By.id("download"))); downloadBtn.click(); // 切回默认页面上下文 driver.switchTo().defaultContent(); </code></pre> <h2 id="异常排查方案">异常排查方案 <a class="header-anchor" href="#异常排查方案" aria-hidden="true">#</a></h2> <p>如果按上述代码仍无法定位:</p> <ol> <li>切换到iframe后打印当前页面源码,确认下载按钮是否存在于当前上下文</li> <li>若按钮处于shadow DOM节点内,需要先获取shadow root再穿透定位</li> </ol> <p>内容的提问来源于stack exchange,提问作者Shubt</p>
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起
模型再升级,30秒超长叙事, 模态参考扩容
模型自由,工具不限,最新支持 Deepseek-V4 系列、GLM-5.3 系列
超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列
大模型19元起,Al应用9.9元畅享,新人首购爆款尽享优惠