Python Forum

Full Version: WebDriverWait visibility isnt defined
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when assigning elements to WebDriverWait do i need to keep the elemet name the same whem calling it with EC? for example
popUp2 = WebDriverWait(browser ,16).until(visibility_of_popUp2_located(By.XPATH, '//*[@id="Layer_1"]'))
    popUp2.click()
i keep getting visibility of popUp2 is not defined.
so i tried to change the word element to popUp2 in (visibility_of_element_located(By.))

i have to ask the dumb questions or ill just keep running in circles here.

here is what ive been doing dumb but just messing around..

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time

browser = webdriver.Firefox()
browser.get("https://www.duckduckgo.com")

searchbar = browser.find_element_by_id('search_form_input_homepage')
searchbar.send_keys('science news')
searchbar.submit()
time.sleep(5)

sc_news = browser.find_element_by_css_selector("#r1-0 > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > a:nth-child(2)")
sc_news.click()

time.sleep(8)

try:
    element = WebDriverWait(browser,16).until(EC.visibility_of_element_located((By.XPATH ,'/html/body/div[4]/div[2]/div/div/div/span/div/div[5]/div/div/button')))
    popUp1.click()

except:
    popUp2 = WebDriverWait(browser ,16).until(visibility_of_popUp2_located(By.XPATH, '//*[@id="Layer_1"]'))
    popUp2.click()
finally:
    print("i could not find those elements / or your code is wrong")
edit = i see the reason now for the visibility not being defined. i forgot to enter EC.visibility for the popUp2 variable.
also since the site has changed i can not seem to locate the solved button.