【问题标题】:how to add explicit wait in drop down in selenium which is dependent on another Dropdown list? [duplicate]如何在依赖于另一个下拉列表的硒下拉列表中添加显式等待? [复制]
【发布时间】:2017-02-15 10:36:22
【问题描述】:

如何使用 selenium 在下拉列表中添加显式等待,直到找到文本?

【问题讨论】:

  • 没有人能够解决这个问题..所以我再次重新发布它
  • 所以你会继续转发直到有人解决它? :) 这不是本网站的运作方式。
  • 上一个问题因为一些不同的答案变得太乱了
  • @Pope 您应该添加更多详细信息,而不是再次发布相同的问题!将HTML 和您的Java 代码分享为文本

标签: java selenium automation cucumber appium


【解决方案1】:

下面的代码将等到指定的文本不存在..

    int i=0;

    while(i==0)
    {
        try{
            Select select = new Select(driver.findElement(By.xpath("ELEMENT_XPATH")));
            select.getOptions().indexOf(0);
            int ed = select.getOptions().indexOf(0);
            if(ed==0); //check whether it's got your index or not(if not then it will throw error and go to Catch section)
            {
                System.out.println("Pass got.. Index Value");
            }
            i=1; //if it got your index value in drop down then .. exit from loop..
        }catch(org.openqa.selenium.NoSuchElementException NSEE)
        {
            i=0; // iteration will continue until .. you'll not get your index in Drop down.. 
        }
    }

【讨论】:

  • 我必须根据索引等待.. 不像 xpath
  • 好的..你想等..直到下拉列表的值可见?
  • 是的.. 正确.. 正如你看到的第二个下拉是不可见的,直到第一个完成获取整个列表
  • 为此,您必须确定..第一个下拉列表中的哪个“值”将最后加载..或最后可见..(在第一个 DD 中可见的值之后..第二个下拉可见)..你知道价值吗?
  • 我想按索引等待或等到第二个下拉列表可用
猜你喜欢
  • 2017-07-03
  • 1970-01-01
  • 2021-03-12
  • 1970-01-01
  • 2021-05-26
  • 2019-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多