AnsweredAssumed Answered

Interacting with elements within Iframes in BWC modules, using Selenium Webdriver

Question asked by alopez@redk.net on Sep 30, 2015
Latest reply on Oct 6, 2015 by alopez@redk.net
Hello, I am trying to locate elements inside Iframes in bwc modules, but apparently something goes wrong.
To do this i wrote this code:
driver.switchTo().frame(driver.findElement(By.cssSelector("iframe.bwc-frame")));
driver.findElement(By.id("name")).sendKeys("testing name");
Unfortunately i am getting this error: 

Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"name"} 

Also i added an explicit wait before 2nd line, just to try. Like: 
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("name")));
However i get a similar error message:

Exception in thread "main" org.openqa.selenium.TimeoutException: Timed out after 30 seconds waiting for presence of element located by: By.id name

When i saw this problem, i checked the behavior using selenium IDE, writing this test case:
<tr> <td>selectframe</td>
<td>css=iframe.bwc-frame</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>id=name</td>
<td></td>
</tr>
<tr>
<td>sendKeys</td>
<td>id=name</td>
<td>testing name</td>
</tr> 
I could access to the element within Iframe using selenium IDE perfectly.

Given this scenario, I tried by saving the page to an html. Then I located this html and the related files outside from a sugarcrm environment, into my document root (i'm using MAMP).
By the way, my SugarCRM is installed under the same document root.

Once i did this, i executed the test again with selenium webdriver and this html, just changing the url. At this point selenium webdriver is able to find and interact with elements inside frames with the same code that failed at first under a SugarCRM environment.

I don't know what is going wrong, why selenium webdriver is unable to find and interact with elements inside iframes in a bwc modules? 

Outcomes