• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

running the selenium(java) script close the browser

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic