I'm using selenium webdriver + jsoup in java for automation and parsing. Manually I can go on a website and open iframe in a new tab. I want to do this automatically.
I inspected the iframes on websites containing ads, these iframes have src attributre empty or blank. They contain iframes within them, which have src attribute set to, source of iframe. How can I get this URL through code?
I want to open a link, get all iframes, and output the source attribute of those iframes, those sources which firefox would refer me to, if I click "open frame in new tab"
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().pageLoadTimeout(200, TimeUnit.SECONDS);
String baseUrl = "https://www.iplocation.net/";
driver.get(baseUrl);
String source = driver.getPageSource();
List<Element> iframes = doc.getElementsByTag("iframe");
System.out.println("Number of iframes = "+ iframes.size());
System.out.println("URL of 1st iframe: " + iframes.get(0).attr("src”)); // empty