aspose file tools*
The moose likes Testing and the fly likes running the selenium(java) script close the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "running the selenium(java) script close the browser " Watch "running the selenium(java) script close the browser " New topic
Author

running the selenium(java) script close the browser

n.chenththuran
Ranch Hand

Joined: Jun 16, 2004
Posts: 41
I wanted to test the order placement using selenium. I did the following
1. recorded the order placement using selenium IDE(i.e login to the website, find a product , add to basket, fill the payment and submit the order which will direct to order confirmation page)
2. exported the testcase to java
3. Ran the converted testcase using Eclipse

Testcase is executed and order is placed. But, immediately browser is closed. Why is this happening.

my selenium script has been given below

import com.thoughtworks.selenium.*;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.regex.Pattern;
import junit.framework.*;
import junit.framework.Test;

import java.sql.*;

import org.junit.*;

import java.util.regex.Pattern;

public class Order extends SeleneseTestCase {
public void setUp() throws Exception {
setUp("http://stage.tjhughes.fresca.co.uk/pws/Home.ice", "*chrome");
}



public void testNew() throws Exception {


selenium.open("/");

assertEquals("TJ Hughes - TJ Hughes - Home", selenium.getTitle());
selenium.click("link=Mobile Phones");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - TJ Hughes - Category List", selenium.getTitle());
selenium.click("//img[@alt='view details']");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - Slider Style Handset With Built In 2 Megapixel Camera.", selenium.getTitle());
selenium.click("addToBasket");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - Slider Style Handset With Built In 2 Megapixel Camera.", selenium.getTitle());
selenium.click("//img[@alt='check out now']");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - TJ Hughes - Login / Register", selenium.getTitle());
selenium.type("j_username", "nadarajah.chenththuran@yahoo.com");
selenium.type("j_password", "09111989");
selenium.click("//form[@id='loginForm']/fieldset/div[2]/div[3]/input");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - TJ Hughes - Select Delivery Address", selenium.getTitle());
selenium.click("//form[@id='chooseAddress']/fieldset/div[3]/input");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - TJ Hughes - Payment Details", selenium.getTitle());
selenium.type("paymentCardHolder", "Tom");
selenium.select("cardType", "label=VISA");
selenium.type("cardNumberError", "4111111111111111");
selenium.type("cardCVSNumberError", "123");
selenium.select("cardStartMonth", "label=01");
selenium.select("cardStartYear", "label=2009");
selenium.select("cardExpiryMonth", "label=01");
selenium.select("cardExpiryYear", "label=2011");
selenium.click("termsAndConditions");
selenium.click("//form[@id='paymentDetails']/fieldset[2]/div[16]/input");
selenium.waitForPageToLoad("30000");
assertEquals("TJ Hughes - TJ Hughes - Order Confirmation", selenium.getTitle());
}



public static Test Suite(){
return new TestSuite(Order.class);

}



public static void main(String args[]){
junit.textui.TestRunner.run(Suite());
}


I will appreciate your reply.

Thanks in advance.

Chenththuran

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: running the selenium(java) script close the browser
 
Similar Threads
JUnit Threads still running after test ends
selenium, testng, eclipse processing a form
Unable to locate the element while executing TC as JUNIT but it is working fine in IDE
Selenium RC Junit test case does not execute.
Junit4+Eclipse+Selenium RC- Test class should have exactly one public zero-argument constructor