I'm using google colab to run stable diffusion and I want to make a txt file with all the prompts and settings. These are located in a div class element under the generated image in the web ui. I want a python code to copy the text (with the promots and settings) and save it in a txt file each time I enter a filename.
This is my code
from selenium import webdriver
browser = webdriver.Firefox()
browser.get('https://1234.gradio.live')
while True:
folder_path = input("Enter folder path to save text files: ")
file_name = input("Enter file name to save text: ")
if file_name == 'stop':
break
file_path = folder_path + '\\' + file_name + '.txt'
transition_div = browser.find_element_by_xpath('//div[@class="transition"]')
p_elements = transition_div.find_elements_by_tag_name("p")
p_texts = [p.text for p in p_elements]
with open(file_path, 'w', encoding='utf-8') as f:
for p_text in p_texts:
f.write(p_text + '\n')
print(f"Text saved in {file_path}")
browser.quit()
This is the error that I'm getting:
Traceback (most recent call last):
File "C:\User\..\selenium firefox.py", line 13, in <module>
transition_div = browser.find_element_by_xpath('//div[@class="transition"]')
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'
How do I fix this?