Issue
Hello I try to get some data from a web page with selenium. But some weird things happen that I doesn't understand. When I run my programm step by step with the debugger it works but running normaly it doesn't. I haven't seen any post related on python or selenium on the internet. Here is my code :
import undetected_chromedriver as uc
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
if __name__ == '__main__':
L=[]
PATH="C:\Program Files (x86)\chromedriver.exe"
options=uc.ChromeOptions()
pref={"download.default_directory" : r"C:\Users\Dimitri\Documents\Programme C++\clis\extraction+sql\ressources"}
options.add_experimental_option("prefs",pref)
options.headless=True
driver=uc.Chrome(excutable_path=PATH,options=options)
driver.get("https://framagenda.org/login?redirect_url=/apps/calendar/dayGridMonth/now")
user = driver.find_element("id","user")
user.send_keys("[email protected]")
mdp=driver.find_element("id","password")
mdp.send_keys("test123")
mdp.send_keys(Keys.RETURN)
print(driver.title)
list=driver.find_elements(By.CLASS_NAME,"app-navigation-entry__title")
for l in list:
L.append(l.text)
print(L)
for l in L:
driver.get("https://framagenda.org/remote.php/dav/calendars/Dimitri%20L./"+l.lower()+"/?export")
Note that i doesn't understand the first if of the problem i put it here for fixing an error that i've seen on this forum
When the code is running normally the line :" list=driver.find_elements(By.CLASS_NAME,"app-navigation-entry__title")" seems not to be executed Have you any idea of what's going wrong ?
Thank you for your help
Solution
Thanks for your responses and sorry for not being clear enough. I finally succeeded to address my issue. The problem was that when i ran my code normally the webpage wasn't loading fast enough as a consequence my program was not able to get the element it needed because the webpage was not loaded though when i uses step by step the webpage had enough time to load. I fixed the issue using time.sleep(2) before getting the data that I want
Answered By - dim lanier
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.