Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » General (non-technical) » Test » TestSuite(Problems with Login)
TestSuite [message #668133] Tue, 03 May 2011 18:18
Cecilia  is currently offline Cecilia
Messages: 1
Registered: May 2011
Junior Member
Hi guys!

I'm new in JUnit Tests. I'm combining Selenium RC and Eclipse to create test cases, and I'm facing a problem. I have a serie of cases that I want to run in a Test suite (all them are working properly separately). The issue here is as follows:

First I need to login (so I create a test case to let me login), once I'm logged I need to use the same window (logged) to continue testing more cases, but if I try to use the same window once the next test case starts to run it show me an error so I need to repeat the procedure of login for each case and I don't want to do that. I only want to login once and then continue working on the same page.

Could somebady help my please???? Confused Confused

This is my login class

public class MyLogin extends TestCase{

Selenium selenium;
@Before
public void setUp() throws Exception {
selenium = new DefaultSelenium("localhost",4444,"*chrome","http://mypage.com");
selenium.start();
}

@Test
public void testMyLogin()throws Exception{

selenium.open("http://mypage/login");
selenium.type("username", "admin@mypage.com");
selenium.type("password", "myadminpass");
selenium.click("submit");
Thread.sleep(15000);
}
}


And this is the case I want to run next to login :

public class Top5Prices extends TestCase{
Selenium selenium;

//@Before
//public void setUp() throws Exception {
//selenium = new //DefaultSelenium("localhost",4444,"*chrome","http://mypage.com/onesection/blabla");
//selenium.start();
}
public void VerifySortingByPrice(){

bla bla bla.....
}
@Test
public void testTop5Prices () throws Exception {

///Login just for test this case, once the case run properly this part must be removed
//selenium.open("http://mypage.com/login");
//selenium.type("username", "admin@mypage.com");
//selenium.type("password", "myadminpass");
//selenium.click("submit");
//Thread.sleep(15000);
////////////////////////////////

//selenium.open("http://mypage.com/onesection/blabla");
Thread.sleep(15000);

VerifySortingByPrice();

Integer row = 4;
Integer tebdy = 3;

int size = selenium.getXpathCount("//table[@id='data_table']/tbody/tr").intValue();
System.out.println("size = " + size);

String NameItem = selenium.getText("//table[@id='data_table']/tbody/tr[" + row + "]/td[2]");
System.out.println("name item: " + NameItem);

.....
....
.....
blablabla
}



Thanks Very Happy
Previous Topic:test
Next Topic:Just a test
Goto Forum:
  


Current Time: Wed Apr 23 02:51:08 EDT 2014

Powered by FUDForum. Page generated in 0.02266 seconds