- Klau
- Posts : 8
Join date : 2012-12-04
Location : Romania
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:
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:
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!
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!
- selenium.isTextPresent() and selenium.isElementPresent() are NULL
- Creating detail log for selenium command execution (Selenium RC Java client)?
- How to locate a particular string on a webpage using selenium commands
- pass string variable from database in to variable and then insert into 3rd party website using selenium and click search button.
- Can Selenium do image comparison tests; support mobile browsers; and other FAQs about Selenium
Permissions in this forum:
You cannot reply to topics in this forum