how to check the text entered before and after login remain unchanged


hi all,

I have few text fields like ‘Title’, ‘Message’
I need to enter text into this fields,
after that I need to login into application,
after successfully login, the text entered should be remain unchanged

How can I code to check the text entered before and after login remain unchanged, how can I do this? Thanks.

Add Comment
3 Answer(s)
Best answer

Try taking a look at this code. Pay attention to getAttribute method of WebElement

InternetExplorerDriver idriver = new InternetExplorerDriver();

idriver.findElementByName(“q”).sendKeys(“Cucumber selenium”);

System.out.println(“Text value is ” + idriver.findElementByName(“q”).getAttribute(“value”));


Virender Singh Professor Answered on March 3, 2015.

Hi Virender,

Thanks for your suggestion, it works.

how about IF the element is iframe, it is a wysiwyg text area, how to get the text entered

// Enter text for Message field


public static WebElement txt_keyInMessage() throws Exception{


WebElement iframeMsg= driver.findElement(By.xpath("//*[contains(@class, 'wysiwyg_frame')]"));


driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);

element = driver.findElement(By.cssSelector("body"));

}catch (Exception e){



return element;


iframe html

<iframe class="wysiwyg_frame" frameborder="0" src="" style="width: 100%; height: 100%;" title="Rich Text Editor, contact_remarks" aria-describedby="cke_30" tabindex="0" allowtransparency="true">

<!DOCTYPE html>

<html lang="en" dir="ltr">


<body class="cke_editable cke_editable_themed cke_contents_ltr cke_show_borders" contenteditable="true" spellcheck="false">


hello, pls contact me once you received this message






eg. text entered here is
“hello, pls contact me once you received this message”
but in iframe wysiwyg text area, it don’t have ‘value’ type
please advice, thanks.

on March 4, 2015.
Add Comment

Switch to iFrame and then do gettext() for the element “body”

raj224in Default Answered on March 4, 2015.
Add Comment

Try this

String element = driver.findElement(By.xpath(“//*[@class=’cke_editable cke_editable_themed cke_contents_ltr cke_show_borders’]/p”)).getText();

amitjain Supporter Answered on March 10, 2015.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.