Get element from CQ class using Selenium

Question:

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')
Asked By: lightspeed192

||

Answers:

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.

Answered By: Refet
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.