【发布时间】:2023-03-20 08:15:01
【问题描述】:
如何使用 Java 和 Selenium 调整大小?
我一直在尝试的代码:
public static void main(String[] args) throws InterruptedException
{
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(10));
driver.get("https://jqueryui.com/resizable/");
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.switchTo().frame(0);
Thread.sleep(2000);
WebElement resize = driver.findElement(By.xpath("//div[@id = 'resizable']/div[3]"));
//WebElement resize = driver.findElement(By.id("resizable"));
new Actions(driver).dragAndDropBy(resize, 400, 400).perform();
}
这是以下错误:
> Exception in thread "main"
> org.openqa.selenium.interactions.MoveTargetOutOfBoundsException: move
> target out of bounds
【问题讨论】:
-
您只能在外部矩形内调整内部矩形的大小。首先获取外部矩形的边界,然后查看可以调整内部矩形大小的可能值。
-
我可以得到以下答案的一些更新吗?
标签: java selenium selenium-webdriver selenium-chromedriver resize