我正在使用 JavaScript 自动化网页,但在自动化时我无法点击隐藏在滚动后面的链接。我为水平滚动编写了代码,但它不起作用。那么你能帮助我如何水平滚动,以便我可以点击链接
这是我的代码:
LinkPath = sampleUtility.getXpathEntity(driver,
exlXpath.get("LNK_SAMPLE_DATASET").toString(),
DSetName,
exlXpath.get("LNK_DATASET_DELETE").toString());
Thread.sleep(min_wt);
WebElement box = driver.findElement(
By.xpath(exlXpath.get("LNK_SAMPLE_DATASET").toString()));
try{
try{
driver.findElement(By.xpath(LinkPath.toString())).click();
((JavascriptExecutor) driver).executeScript("arguments[0].scrollRight();", box);
}catch(Exception e){
((JavascriptExecutor) driver).executeScript("arguments[0].scrollRight();", box);
}
driver.findElement(By.xpath(LinkPath.toString())).click();
}
catch(Exception e){}