Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» FlexMonkium Download Not available under Gorillalogic site
Thu Dec 08, 2016 5:40 pm by bhanu.praveen

» Selenium Script issue
Tue Dec 06, 2016 9:48 pm by njain213

» Difference between QTP, Selenium and Silk test
Tue Dec 06, 2016 7:58 pm by jessicacyrus1

» Where does selenium script pick browser from
Tue Dec 06, 2016 1:52 pm by janbaskt

» Safari throws an HTTP ERROR: 404
Tue Dec 06, 2016 1:51 pm by janbaskt

» Access Denied Error in Selenium RC
Tue Dec 06, 2016 1:51 pm by janbaskt

» Automating Flex application through selenium webdriver
Fri Dec 02, 2016 2:06 pm by abhinay.krs

» Starting with Selenium, what is Selenium?
Mon Nov 28, 2016 4:00 pm by Foma

» Getting started with Selenium
Mon Nov 28, 2016 3:23 pm by Rebbelx

Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

View previous topic View next topic Go down

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

Post by Klau on 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

Klau

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

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