简体   繁体   English

我在点击图片海报时遇到ElementNotVisible问题

[英]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.

相关问题 运行我的应用程序时,我在 Flutter 中遇到问题 - I am facing issue in Flutter while run my application 使用Selenium WebDriver代码单击下拉按钮时遇到问题 - Facing issue while clicking dropdown button using selenium webdriver code 尝试在“ Windows 8.1”操作系统中更新“ Java”时遇到问题 - I am facing issue while trying to update “Java” in “windows 8.1” OS 我正在尝试使Restful Webservice及其客户端成为传递XML时遇到的问题 - I am trying to make Restful Webservice and it's client,facing issue while passing XML 我在使用 android studio 开发 android 应用程序时遇到了 minCompileSDK 问题 - I am facing an minCompileSDK issue while developing an android app using android studio 我在通过 Apache POI 添加计算字段时遇到问题 - I am facing an issue while adding calculated field through Apache POI 我在使用 selenium java 在 html5 中拖放时遇到问题 - I am facing issue in drag and drop in html5 with selenium java 如何在Firestore数据库中运行多个事务? 我面临的问题是 - How to run the multiple transactions in Firestore database? I am facing issue in that 我面临 dateFormat.parse(string) 的问题? - Issue i am facing with dateFormat.parse(string)? 升级到 jboss wildfly 时遇到以下错误 - I am facing the following error while upgrading to jboss wildfly
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM