You need to use explicit wait for the result ready. JS rendered element cannot be obtained without waiting. Neither simple requests, nor selenium without waiting.
wait = WebDriverWait(driver, 10)
element = wait.until(element_has_text(By.XPATH, '//a[contains(@class, "btn")]'))
class element_has_text(object):
def __init__(self, locator, css_class):
self.locator = locator
def __call__(self, driver):
element = driver.find_element(*self.locator) # Finding the referenced element
if element.text:
return element
else:
return False
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.