1WebDriverWait wait = new WebDriverWait(driver, 20);
2wait.until(ExpectedConditions.elementToBeClickable(lastElementToLoad));
3
1from selenium import webdriver
2from selenium.webdriver.common.by import By
3from selenium.webdriver.support.ui import WebDriverWait
4from selenium.webdriver.support import expected_conditions as EC
5
6driver=webdriver.Firefox()
7driver.get("http://www.example.com") #This is a dummy website URl
8try:
9 elem=WebDriverWait(driver,10).until(
10 EC.presence_of_element_located((By.ID,"Element_to_be_found")) #This is a dummy element</span>
11 )
12finally:
13 driver.quit()
14
1<span class="kn">from selenium import webdriver
2from</span> <span class="nn">selenium.webdriver.common.by</span> <span class="k">import</span> <span class="n">By</span>
3<span class="kn">from</span> <span class="nn">selenium.webdriver.support.ui</span> <span class="k">import</span> <span class="n">WebDriverWait</span>
4<span class="kn">from</span> <span class="nn">selenium.webdriver.support</span> <span class="k">import</span> <span class="n">expected_conditions</span> <span class="k">as</span> <span class="n">EC</span>
5
6<span class="n">driver</span> <span class="o">=</span> <span class="n">webdriver</span><span class="o">.</span><span class="n">Firefox</span><span class="p">()</span>
7<span class="n">driver</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"http://www.example.com"</span><span class="p">) #This is a dummy website URL</span>
8<span class="k">try</span><span class="p">:</span>
9 <span class="n">elem </span><span class="o">=</span> <span class="n">WebDriverWait</span><span class="p">(</span><span class="n">driver</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span><span class="o">.</span><span class="n">until</span><span class="p">(</span>
10 <span class="n">EC</span><span class="o">.</span><span class="n">presence_of_element_located</span><span class="p">((</span><span class="n">By</span><span class="o">.</span><span class="n">ID</span><span class="p">,</span> <span class="s2">"Element_to_be_found"</span><span class="p">)) #This is a dummy element</span>
11 <span class="p">)</span>
12<span class="k">finally</span><span class="p">:</span>
13 <span class="n">driver</span><span class="o">.</span><span class="n">quit</span><span class="p">()</span>
14