Used By: WebDriver, C #

HAVE
There is a page with a div ... / div.
The content of the div ... / div after each page refresh is not predicted to change.

Those.
Var 1 div empty / div
Var 2 div ... set of elements ... / div

QUESTION
How to implement the script: if the div is empty / div, then refresh the page?

    1 answer 1

    Refresh this page using driver.Navigate().Refresh(); , check the .Text value of the desired item

     var div = driver.FindElement(By.TagName("div")); if(string.IsNullOrWhiteSpace(div.Text)) { driver.Navigate().Refresh(); } 
    • There is a lot of div on the page. How to make the solution you offer work with the right div? - koverflow
    • one
      @koverflow what in your understanding is the right div? How do you determine which of a dozen div you need exactly one? on what grounds? - tCode
    • @ tCode Seems understood. I will identify it by id - koverflow
    • @koverflow then: var div = driver.FindElements(By.TagName("div")).First(e => e.GetAttribute("id") == "некоторый id"); - tCode