Selenium C# WebDriver: Wait until element is present

前端 未结 24 3057
礼貌的吻别
礼貌的吻别 2020-11-22 08:53

I want to make sure that an element is present before the webdriver starts doing stuff.

I\'m trying to get something like this to work:

WebDriverWait w         


        
24条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 09:50

    Was searching how to wait in Selenium for condition, landed in this thread and here is what I use now:

        WebDriverWait wait = new WebDriverWait(m_driver, TimeSpan.FromSeconds(10));
        wait.Until(d => ReadCell(row, col) != "");
    

    ReadCell(row, col) != "" can be any condition. Like this way because:

    • it's mine
    • allows inlining

提交回复
热议问题