I'm using xpath to scrape information from a dynamic html table. The information I'm trying to scrape is inside of a tag called #document and I'm not sure how to include this in the xpath since it doesn't follow the normal <>...</> format of most html elements. I also don't have the option to select the xpath when I open the options to the left of the tag in the inspector. What do I do here? I've included a snippet below of the tag I'm referring to.
<iframe>
#document
<html>...</html>
</iframe>
CodePudding user response:
The <html> underneth the #document is within an <iframe>. To access the elements within that <html> you have to:
Induce WebDriverWait for the desired frame to be available and switch to it as follows:
WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"iframe_xpath")))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
