Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

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

Tue Mar 05, 2013 7:06 pm
Hi,

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):
IDE:

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

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:

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;

   @Before
   public void setUp() throws Exception {
      selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://www.dice.com/");
      selenium.setSpeed("2000");
      selenium.start();
      selenium.windowMaximize();
      selenium.windowFocus();
   }

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

   @After
   public void tearDown() throws Exception {
      selenium.stop();
   }
}

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