Here I have tried to access leetcode question title, which are available on the given link. However I seem to not be able to access the text in the specified web element. The error I get says:
AttributeError: 'list' object has no attribute 'text'
I also get a warning:
service = Service(executable_path=gecko, log_path='geckodriver.log')
DeprecationWarning: log_path has been deprecated, please use log_output
Please help me fix these, since I cannot find any solution which does not return the same error.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.service import Service
# URL of the page with questions
url = 'https://leetcode.com/problemset/all/?page=1&topicSlugs=array'
gecko= 'path'
i = 3
# XPath expression for the elements containing the text
xpath_expression = f"/html/body/div[1]/div/div[2]/div[1]/div[1]/div[5]/div[2]/div/div/div[2]/div[1]/div[2]/div/div/div/div/a"
firefox_path="path"
options = Options()
service = Service(executable_path=gecko, log_path='geckodriver.log')
driver = webdriver.Firefox()
driver.get(url)
element = driver.find_elements(By.XPATH, xpath_expression)
element_text = element.get_attribute('text')
print(element_text)
driver.quit()