I need to type data into an iframe
. I referred to
Typing in a IFrame with Selenium IDE
but selenium.selectFrame(<xpath>)
returns: Element not found error
and no css has been defined for the iframe
.
Using firebug:
<iframe frameborder="0" allowtransparency="true" tabindex="0" src="" title="Rich text editor, templateWizardCKEditor1, press ALT 0 for help." style="width: 100%; height: 100%;"/>
What could be a solution for this?
I found a solution for the same...
driver.switchTo().frame("ext-gen298");
WebElement editable = driver.switchTo().activeElement();
editable.sendKeys("Your text here");
driver.switchTo().defaultContent();
Ref: http://code.google.com/p/seleniumwikiFrequentlyAskedQuestions#Q:_How_do_I_type_into_a_contentEditable_iframe?
That just means you used some bad xpath.
selenium.selectFrame("xpath=//iframe[contains(@title,'Rich text editor')]");
This should work. It selects the iframe based on an xpath expression that looks for an iframe which title attribute contains "Rich text editor".
For more xpaths, see XPath v1.0 on w3.org and XPath v2.0 on w3.org - only for some browsers.
By the way, the iframe can be selected by css selectors, too, even if it has no css assigned. The selector can select any element based on its position in tree hierarchy and it's attributes - similar to XPath. To learn about css selector, try The w3 again or wikipedia
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With