I can't define webelement as it has dynamic id and name. There are iframe in another iframe. Attributes id and name for second iframe are dynamic. I need to define the second iframe to switch on it http://prntscr.com/pqshpr Please help me with defining this dynamic elements.
WebElement chartFrameFirst = driver.findElement(By.xpath("(.//iframe)[1]"));
driver.switchTo().frame(chartFrameFirst);
click(By.xpath(".//div[@id=\"tv_chart_container\"]"));
WebElement chartFrameSecond = driver.findElement(By.xpath(".//iframe[@id=\"tradingview_1d329\"]"));
driver.switchTo().frame(chartFrameSecond);
We can use contains()
which is a method used in XPath expression as shown below
WebElement chartFrameSecond = driver.findElement(By.xpath(".//iframe[contains(@id,\"tradingview_\")]"));