java - How to select new IFrame using Selenium WebDriver? -


I want to select an iframe and enter value in the body. I'm trying with code below.

HTML code:

  & lt; IFrame id = "4564654_content_ifr" & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Body id = "small" & gt; & Lt; Div aria-lable = "new composition body" & gt; & Lt; Br> & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Head & gt; & Lt; / Html & gt; & Lt; / IFrame & gt;  

selenium code:

  driver. SwitchTo (). Frame (driver.findElement (By.xpath ("// iframe"))) [(@ id, 'content_ifr')]; Driver.findElement (By.xpath ("// * [@ id = 'tiny'] / div [1]")))). SendKeys ("Happy New IFrame");  

But I could not be able to enter the values ​​

Can anyone help me with it? Instead of sending keys to

, you set innerHTML directly.

  driver. SwitchTo (). Frame (driver.findElement (By.xpath ("// iframe [in (id id, 'content_ifr')]"))); Web Element Body = Driver.Fed Element (Bay CCSelector ("body"); (JavascriptExecutor) driver.executeScript ("argument [0] .innerHTML = 'Happy New IFrame'", body);  

If you are testing some kind of WYSIWYG editor TinyMCE, feel free to see this article:

Then You're probably able to set the content directly through the editor's API. Firefox has a problem with sendkeys , but should be fine with chrome or funmos.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -