Display results as :
Advanced Search

Go down
Posts : 8
Join date : 2012-12-04
Location : Romania

Selenium RC verifyTrue(selenium.isTextPresent(“string”)) Empty Selenium RC verifyTrue(selenium.isTextPresent(“string”))

on Tue Mar 05, 2013 7:06 pm

I have a few questions regarding the Selenium RC -> VerifyTextPresent command
By example: (verifyTrue(selenium.isTextPresent()));

I found an spelling error in the text on the page when running the test from the Selenium IDE, but the error was not caught when running the test via Selenium RC/JUnit.

I understand that I need to add the method: checkForVerificationErrors(); to java code to have the same result as in IDE.

For example this code/line (verification):

   <td>Search results: 1 - 30 of 50</td>

Selenium RC/JUnit: verifyTrue(selenium.isTextPresent("Search results: 1 - 30 of 50"));

After I added checkForVerificationErrors(); Selenium RC it works as IDE.

Here is the complete code:

package com.example.tests;

import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.regex.Pattern;

public class Dice_Search extends SeleneseTestCase {
   private Selenium selenium;

   public void setUp() throws Exception {
      selenium = new DefaultSelenium("localhost", 4444, "*firefox", "");

   public void testDice_Search() throws Exception {"/");
      selenium.type("id=FREE_TEXT", "selenium");
      selenium.type("id=zipCodeCity", "Los Angeles, CA");"id=searchSubmit");
      verifyTrue(selenium.isTextPresent("Search results: 1 - 30 of 50"));
      verifyTrue(selenium.isTextPresent("Create Search Agent Matching These Results"));
      verifyEquals("selenium", selenium.getText("css=div.undoLabel"));

   public void tearDown() throws Exception {

Now the questions:

1. How is much better to add checkForVerificationErrors(); after each (verifyTrue(selenium.isTextPresent())); line or can be added at the end of the test like in the above code?

2. How can I know at what line in Selenium RC/JUnit the test is failed? In Selenium IDE in the Log window it's show the line, also the command is marked with red. In JUnit only show a Failure Trace, not the line which produced the test error.

Thank you!
Have a nice day!

Last edited by Klau on Tue Mar 05, 2013 7:37 pm; edited 5 times in total
Back to top
Permissions in this forum:
You cannot reply to topics in this forum