Python Forum
WebDriverWait visibility isnt defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WebDriverWait visibility isnt defined
#1
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  WebDriverWait improved function euras 0 1,481 Jun-02-2021, 01:40 PM
Last Post: euras
  WebDriverWait Truman 4 5,895 Mar-26-2019, 09:59 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020