请仔细阅读此堆栈溢出答案以更好地理解。@H_404_1@
我们也可以尝试@H_404_1@
There are many Conditions that we can use withing Webdriver tests.
1. visibilityOf(WebElement element) : An expectation for checking that an element, kNown
to be present on the DOM of a page, is visible.
2. visibilityOfElementLocated(By locator) : An expectation for checking that an element
is present on the DOM of a page and visible.
In the above two conditions we are waiting for an element to be present on the DOM
of a page and also visible. These works fine only when the element is loaded completely.
也请尝试如下@H_404_1@
尝试使用Y坐标单击@H_404_1@
WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));
// Scroll the browser to the element's Y position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().y+")");
// Click the element
elementToClick.click();
尝试使用X坐标单击@H_404_1@
WebElement elementToClick = driver.findElement(By.xpath("Your xpath"));
// Scroll the browser to the element's X position
((JavascriptExecutor)driver).executeScript("window.scrollTo(0,"+elementToClick.getLocation().x+")");
// Click the element
elementToClick.click();
希望这对您有帮助@H_404_1@