Right now I'm working on a program that takes user input of questions and answers, separates them into separate lists of q's and a's, then automatically answers the question given either the question or answer. Since the place where the 'bot' is being used is online, I'm using the Selenium web driver, which is causing me some problems when trying to read an aria-label. I don't know what I'm doing wrong, as I'm not advanced at all with selenium, HTML, or CSS. I'm trying to find the aria-label value for each container without knowing what it is
An example of the HTML I'm trying to get the text value of:
<div class="MatchModeQuestionGridBoard-tile"><div class="MatchModeQuestionGridTile" touch-action="auto"><div class="MatchModeQuestionGridTile-content"><div aria-label="to cloak; to conceal the truth; to offer lame excuses" class="FormattedText notranslate TermText MatchModeQuestionGridTile-text lang-en" style="font-size: 14px;"><div style="display: block;">to cloak; to conceal the truth; to offer lame excuses</div></div></div></div></div>
Snippet of my code:
def driver():
driver = webdriver.Chrome()
driver.get(link)
startMatch = driver.find_element_by_xpath("/html/body/div[5]/div/div/div/div[2]/button").click()
#find text in matches
container = driver.find_elements_by_class_name('MatchModeQuestionGridTile-content')
containerFile = open("QuizletTerms.txt", "w+")
for _ in list(container):
arialabel = driver.find_elements_by_css_selector("div[aria-label='']")
containerFile.write("\n")
containerFile.write(str(arialabel))
print(arialabel)
containerFile.close()
print("done")
sleep(5)
Output:
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]