Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Geting issues in identifying the elsements in webdriver
Fri Feb 17, 2017 4:41 pm by janbaskt

» WebDriver - why not to use a singlton for it?
Fri Feb 17, 2017 4:40 pm by janbaskt

» WebDriver session when using testng annotation to invoke driver instance
Fri Feb 17, 2017 4:39 pm by janbaskt

» Selenium fails to launch Chrome
Fri Feb 17, 2017 4:39 pm by janbaskt

» why do i get this error
Fri Feb 17, 2017 4:38 pm by janbaskt

» Selenium Tutorial
Thu Feb 16, 2017 5:21 pm by Rahul

» When to use Selenium IDE, RC and WebDriver
Mon Feb 13, 2017 2:35 pm by azharuddin

» How to integrate selenium with ZAPI-Zephyr
Sat Feb 11, 2017 2:25 am by gseera002c

» Selenium Webdriver
Sat Feb 04, 2017 6:47 pm by soumyamishrav@gmail.com

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