Home > database >  Get element from CQ class using Selenium
Get element from CQ class using Selenium

Time:01-28

I want to enter the "Symbol" name and select tab "NSE" from the filter. Once that is done, click on table view button using Selenium. But I cannot find any of these nodes using Debugger.

(https://i.stack.imgur.com/uOrQc.png)

The original class "chart-frame" is found.

driver.find_element(By.ID, "chart-iframe")

I get "No such element" for any of the below commands. I cannot find any information on this CQ tags online.

driver.find_element(By.CLASS_NAME, "ciq-search")
driver.find_element(By.CSS_SELECTOR, "ciq-search")
driver.find_element(By.CSS_SELECTOR, "ciq-DT.tableview-ui")
driver.find_elements(By.XPATH, '//button')

CodePudding user response:

Firstly, you need to switch into that iframe to scrape whatever you wanna scrape. You can use following code snippet for it:

iframe = driver.find_element(By.XPATH, "//iframe[@name='TheIframeName']")
driver.switch_to.frame(iframe)

You can use driver.switch_to.default_content() to switch back to default content.

  • Related