Sunday 29 March 2015

HTML & Web Driver

Enter the data in HTML editior through selenumn web driver-
1.Below is the html code for understanding :-
 <iframe id="message_ifr" frameborder="0" allowtransparency="true" title="Rich Text Area. Press ALT-F9 for menu. Press ALT-F10 for toolbar. Press ALT-0 for help" style="width: 100%; height: 100px; display: block;" src="javascript:""">
<!DOCTYPE html>
<html>
<head>
<style id="mceDefaultStyles" type="text/css">
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<link href="http://cgpdigitallibrary.com/www/js/tinymce/skins/lightgray/content.min.css" rel="stylesheet" type="text/css">
</head>
<body id="tinymce" class="mce-content-body " contenteditable="true" data-id="message" spellcheck="false">
<p>
<br data-mce-bogus="1">
</p>
</body>
</html>
</iframe>
2.Web driver code for to switch in to iframe and enter the data in html box

driver.switchTo().frame("message_ifr");  // this line for switching in to iframe
WebElement element = driver.findElement(By.id("tinymce"));// in iframe search the particular id
System.out.println("Entering something in text input");//For debugging purpose
element.sendKeys(Keys.CONTROL + "a");//for whole text for input
element.sendKeys("note for user famcom");// type in to free text box
driver.switchTo().defaultContent();// it is necessary to move out from html editor to perform new task



No comments:

Post a Comment