Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» how to connect DB in selenium webriver
Fri Oct 06, 2017 4:09 pm by anbarasi

» How find any text in browser screen and click on it?
Thu Oct 05, 2017 2:02 pm by sandeepkommineni

» Selenium Webdriver
Tue Oct 03, 2017 1:35 pm by PiyushBiswas

» GRID setup tutorial.
Wed Sep 27, 2017 4:29 pm by johnyapp

» Drag & Drop Between Windows Using Selenium Driver
Wed Sep 27, 2017 2:10 pm by 26rondel

» Check if window is closed / verify input
Sat Sep 23, 2017 10:21 pm by brainstir

» How to work on pages with AJAX in selenium?
Mon Sep 18, 2017 6:08 pm by azharuddin

» pause test until user press a key like F2
Wed Aug 09, 2017 11:10 pm by djnforce

» Selecting the input for auto populating element
Sat Jul 29, 2017 7:53 pm by kdabbara

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

Asserting Text In WebDriver

View previous topic View next topic Go down

Asserting Text In WebDriver

Post by Latha.p on Tue Feb 05, 2013 11:13 am

Hi,

How can we assertText, assertTextPresent, verifyText, verifyTextPresent in Webdriver.
Can any one please help me?

Latha.p
Active particpant
Active particpant

Posts : 11
Join date : 2013-01-06

Back to top Go down

Re: Asserting Text In WebDriver

Post by er.debu on Tue Feb 05, 2013 12:13 pm

Assert.assertequals(); you can use for matching text/numeric value,boolean value.

boolean bool=driver.findElement(By.xpath("xpath of the text")); it will return true or false.

String text=driver.fidnElement(By.xpath("xpath of the text")).getText();
this will return text of that xpath.Then u can compare with ur expected text by putting Assert.assertequals(text,"your expected text");

er.debu

Posts : 6
Join date : 2013-02-01
Age : 30
Location : Bangalore

Back to top Go down

Re: Asserting Text In WebDriver

Post by Latha.p on Tue Feb 05, 2013 2:06 pm

Thank u very much debu for ur reply.
Ya its worked.
But whats my prob is i tried on one website of asserting text. but i dont know where the mistake is iam getting error

following is the code.
import org.junit.Assert;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;

public class TestAssertText {
public static void main(String[] args){
WebDriver d1=new FirefoxDriver();
d1.get("http://www.sriramatech.com/");
String text=d1.findElement(By.xpath(".header-headertitle")).getText();
Assert.assertEquals(text,"Welcome to ORKL SriRamaTech Enterprises!");
d1.close();
}
}

Please tell me where the mistake is and can u remodified that? Its very urgent for me

Latha.p
Active particpant
Active particpant

Posts : 11
Join date : 2013-01-06

Back to top Go down

Re: Asserting Text In WebDriver

Post by er.debu on Tue Feb 05, 2013 3:24 pm

hi latha,
Pls check below code.Hope it may work.


WebDriver d1=new FirefoxDriver();
driver.get("ur url");
Thread.sleep(5000);
String text=d1.findElement(By.xpath("//*[@id='header']/table/tbody/tr/td[2]/span[1]")).getText();
Assert.assertEquals(text,"Welcome to ORKL SriRamaTech Enterprises!");
d1.close();
}
}

er.debu

Posts : 6
Join date : 2013-02-01
Age : 30
Location : Bangalore

Back to top Go down

Re: Asserting Text In WebDriver

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum