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

Answered

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 Answers
Best answer

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

InternetExplorerDriver idriver = new InternetExplorerDriver();

idriver.get(“http://google.com”);
idriver.findElementByName(“q”).sendKeys(“Cucumber selenium”);

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

Virender

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

ContactUs_Page.txt_keyInMessage().sendKeys(ColMessage);


public static WebElement txt_keyInMessage() throws Exception{

try{

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

driver.switchTo().frame(iframeMsg);

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

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

}catch (Exception e){

throw(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">

<head>

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

<p>

hello, pls contact me once you received this message

<br>

</p>

</body>

</html>

</iframe>

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

Your Answer

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