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
The texts e.g. to cloak; to conceal the truth; to offer lame excuses is present in child <div>
as well in it's parent <div>
. So extract it you need to induce WebDriverWait for visibility_of_all_elements_located()
and you can use either of the following Locator Strategies:
Using CSS_SELECTOR
and get_attribute()
:
print([my_elem.get_attribute("aria-label") for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div.MatchModeQuestionGridTile-content>div[aria-label]")))])
Using XPATH
and get_attribute()
:
print([my_elem.get_attribute("aria-label") for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@class='MatchModeQuestionGridTile-content']/div[@aria-label]")))])
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC