1

I'm trying to log in to a webpage so that I can scrape data from it, but every time I try, i get the error Element Not Visible. The element I'm trying to click is a button inside of a modal window, but the html for that window only appears after a login button is clicked. I can click the login button, but I can't click the teacher button that pops up afterwards. Any ideas?

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

login_url = 'https://edpuzzle.com/'
username = '***'
password = '***'
ChromeDriver = r'C:\Users\admin\Python\chromedriver.exe'

driver = webdriver.Chrome(ChromeDriver)
driver.get(login_url)
driver.find_element_by_css_selector('button.btn.btn-default-
transparent').click()
driver.find_element_by_css_selector('p.modal-title.text-lg.text-center.edp-
role-title')
driver.find_element_by_css_selector('button.btn.white-btn.btn-lg.btn-
block.big-btn.edp-teacher-role').click()

1 Answer 1

1

You're trying to click button before it actually visible. You need to wait some time:

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

driver.get(login_url)
driver.find_element_by_id('edp-login').click()
wait(driver, 10).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "button.btn.white-btn.btn-lg.btn-block.big-btn.edp-teacher-role"))).click()
Sign up to request clarification or add additional context in comments.

1 Comment

Just came here looking for this answer which solved my problem. But I think you meant from selenium.webdriver.common.by import By as the third import.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.