title: How to access URL at src attribute in the iframe?
body: <p>I'm trying to sendKeys in the textfield inside form. But this form is put in the link with src attribute. Attribute src refers to that link is in frame tag.</p>
  
  <p>Here's the HTML code</p>
  
  <pre><code>&lt;div class="fancybox-overlay fancybox-overlay-fixed" style="width: auto; height: auto; display: block;"&gt;&lt;div class="fancybox-wrap fancybox-desktop fancybox-type-iframe fancybox-opened" tabindex="-1" style="width: 647px; height: auto; position: absolute; top: 20px; left: 351px; opacity: 1; overflow: visible;"&gt;&lt;div class="fancybox-skin" style="padding: 15px; width: auto; height: auto;"&gt;&lt;div class="fancybox-outer"&gt;&lt;div class="fancybox-inner" style="overflow: auto; width: 617px; height: 277px;"&gt;&lt;iframe id="fancybox-frame1468468198811" name="fancybox-frame1468468198811" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" scrolling="auto" src="addproductgroup.aspx?q=hS9DFK23Nh8Xk29sPZN9j%2bqXSaPgqztzEsozxWSIrSbx9JdDslfYJg%3d%3d"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;title="Close" class="fancybox-item fancybox-close" href="javascript:;"&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Here is the image of the form in fancybox</p>
  
  <p><a href="http://i.stack.imgur.com/siHQ5.png" rel="nofollow">Form in fancybox</a></p>
  
  <p>I already use this code but it didn't work</p>
  
  <pre><code>WebElement tambahGroup = driver.findElement(By.id("aTambah"));
  tambahGroup.click();
  WebElement iframe;
  iframe = driver.findElement(By.id("fancybox-frame1468468198811"));
  driver.switchTo().frame(iframe);
  String src = ((JavascriptExecutor)driver).executeScript("return arguments[0].attributes['src'].value;", iframe).toString();
  driver.get("http://member.indotrading.com/product/"+src);
  WebElement namaGroup = driver.findElement(By.id("txtProdukGroup"));
  namaGroup.sendKeys("Bunga Mawar");
  WebElement namaGroupEng = driver.findElement(By.id("txtProductGroupEnglish"));
  namaGroupEng.sendKeys("Rose Flower");
  Select indukGroup = new Select(driver.findElement(By.id("ddlParent")));
  indukGroup.selectByVisibleText("BUN6A");
  WebElement btnSave = driver.findElement(By.id("btnAdd"));
  btnSave.click();// Switching to Parent window i.e Main  
  Window.driver.switchTo().defaultContent();
  </code></pre>
  
  <p>And I found this error message</p>
  
  <blockquote>
    <p>Exception in thread "main" org.openqa.selenium.NoSuchElementException:
    Unable to locate element:
    {"method":"id","selector":"fancybox-frame1468468198811"} Command
    duration or timeout: 837 milliseconds For documentation on this error,
    please visit: <a href="http://seleniumhq.org/exceptions/no_such_element.html" rel="nofollow">http://seleniumhq.org/exceptions/no_such_element.html</a></p>
  </blockquote>
  
  <p>How could I reach textfield inside the link, because this link is in iframe tag and fancybox. Big thanks for your help.</p>