<dependency>
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-support</artifactId>
<version>3.0.1</version>
</dependency>
When I'm using code below with phantomjsdriver, I'm not able to find element via css selector - table.b3id-widget-table.b3-widget-table
after switching to Frame. The element is located inside iframe.
Meanwhile I'm able to find this element using Firefox or Chrome binaries with same code. It seems that after switching to frame phantomjs is not enable to find any elements inside iframe. Any clue ?
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("standalone-container-main-widgetIframe")));
driver.switchTo().frame("standalone-container-main-widgetIframe");
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("table.b3id-widget-table.b3-widget-table")));
Another answers suggest to add following options in case if iframes are on the another origin.
String [] phantomJsArgs = {"--ignore-ssl-errors=true", "--ssl-protocol=any", "--web-security=false"};
dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_GHOSTDRIVER_CLI_ARGS, phantomJsArgs);
dCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomJsArgs);
But it does not help for me. The weirdest thing that sometimes it worked few times, 1 time from 50 attempts somehow. I changed different timeouts, implicit awaits, explicit awaits - nothing helps, even wait for 3-4 minutes. Seems it is not the timing issue. Also I noticed that my iframe has no src attribute, maybe that's the issue
<iframe frameborder="0" src="about:blank" id="standalone-container-main-widgetIframe">
Also I took screenshot using PhantomJs and looks like the page is loaded successfully including nested iframes, screenshot is trimmed for some reason thought.