[英]I am facing ElementNotVisible issue while clicking on image poster
I am facing ElementNotVisible issue while clicking on image poster in image section with next and back arrow (< >). 单击带有下一个和后退箭头(<>)的图像部分中的图像海报时,我遇到ElementNotVisible问题。 Image posters are changing in some time interval like on image is right now child but after some time period same becomes parent or hide and other becomes chick.
图像张贴者在某个时间间隔内发生变化,例如图像现在是孩子,但是在一段时间之后,它们变成了父代或生皮,而其他变成了小鸡。 It changes dynamically.
它是动态变化的。
Below is the code: 下面是代码:
while(!isFound)
{
Thread.sleep(7500);
driver.findElement(By.xpath("(//a[contains(text(),'Prev')])[2]")).click();////Clicking on Back/Prevous arrow
if(driver.findElement(By.xpath("(//a[@id='carousel-item-3025']/img)[2]")).isDisplayed())
{
driver.findElement(By.xpath("(//a[@id='carousel-item-3025']/img)[2]")).isFound=true;
break;
}
Please provide the solution. 请提供解决方案。
You should wait until required element becomes visible: 您应该等待,直到所需元素可见:
WebDriverWait wait= new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//a[@id='carousel-item-3025']/img)[2]"))).click();
Note that this code should wait not more than 10
seconds for element to become visible. 请注意,此代码应等待不超过
10
秒才能使元素可见。 If full cycle of images rotation is more than 10
seconds you should set more time to wait 如果图像旋转的整个周期超过
10
秒,则应设置更多时间等待
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.